package com.emm.yixun.mobile.ui.signed;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.adapter.AnnexAdapter;
import com.emm.yixun.mobile.adapter.JJAdapter;
import com.emm.yixun.mobile.adapter.NewFromAdapter;
import com.emm.yixun.mobile.adapter.PhoneSelectAdapter;
import com.emm.yixun.mobile.application.EmmApplication;
import com.emm.yixun.mobile.base.BaseActivity;
import com.emm.yixun.mobile.customview.BottomSheet;
import com.emm.yixun.mobile.fragment.CustomerFragment;
import com.emm.yixun.mobile.model.AddSigned;
import com.emm.yixun.mobile.model.AddpirModel;
import com.emm.yixun.mobile.model.GetConsultantList;
import com.emm.yixun.mobile.model.GetConsultantList.ConsultantList;
import com.emm.yixun.mobile.model.GetCustomerDetail;
import com.emm.yixun.mobile.model.GetCustomerList;
import com.emm.yixun.mobile.model.GetDictionaryList.RqBusNumList;
import com.emm.yixun.mobile.model.GetHousesDetail;
import com.emm.yixun.mobile.model.GetRecommendCustomerListHander;
import com.emm.yixun.mobile.model.GetSignedDetail;
import com.emm.yixun.mobile.model.GetSignedHaveAmount;
import com.emm.yixun.mobile.model.NewClassKehuModel;
import com.emm.yixun.mobile.model.NewGetDictionaryList;
import com.emm.yixun.mobile.ui.CustomerListActivity;
import com.emm.yixun.mobile.ui.housing.HousingresourcesActivity;
import com.emm.yixun.mobile.ui.subscribe.NewSubscribeActivity;
import com.emm.yixun.utils.ToastUtils;
import com.eroad.product.tools.MyGridView;
import com.eroad.product.tools.MyListView;
import com.eroad.product.tools.PickerView;
import com.eroad.product.tools.PickerView.onSelectListener;
import com.eroad.product.tools.PopuContent;
import com.eroad.product.tools.Time_SelectPicPopupWindow;
import com.google.gson.Gson;
import com.kyleduo.switchbutton.SwitchButton;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nui.multiphotopicker.model.ImageItem;
import com.nui.multiphotopicker.view.ImageBucketChooseActivity;
import com.yanzhenjie.album.Album;
import com.yixun.app.viewpagerandimag.sample.ViewPagerActivity;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import xf.tools.Loading;
import xf.tools.popu.SelectPicPopupWindow_Test;

/**
 * <p>
 * <b>Title：</b> 新增签约
 * </p>
 * <p>
 * <b>Description：</b>
 * </p>
 *
 * @author tangxin
 * @date 2016年12月6日 下午4:09:57
 */
public class NewSignedActivity extends BaseActivity {

    private static final String TAG = "NewSignedActivity";
    private static final int SELECT_CUSTOMER = 2;
    private static final String[] PAY_TYPES = new String[]{
            "一次性付款", "分期付款", "商业按揭"
    };

    /**
     * 审批是否显示 true 显示 false 隐藏
     */
    private boolean IsDis = false;

    /**
     * 签约ID
     */
    private String signId = "";

    /**
     * 1新增 非1修改 5无房认筹转签约(或6认购转签约) 12修改
     */
    private String OpenType = "1";

    /**
     * 认购ID
     */
    private String subscribeId = "";

    /**
     * 认购编号
     */
    private String subscribeCode = "";

    /**
     * 认购金额
     */
    private String subscribeAmount = "";

    /**
     * 客户ID
     */
    private String customerId = "";

    /**
     * 房源ID
     */
    private String FrdID = "";

    /**
     * 折扣比例
     */
    private String Hdnumber = "0";

    /**
     * 折扣金额
     */
    private String Hdprice = "0";

    /**
     * 认筹ID
     */
    private String payDepositId = "";

    /**
     * 认筹编号
     */
    private String payDepositCode = "";

    /**
     * 认筹金
     */
    private String payDepositMoney = "";

    /**
     * 签约房源
     */
    EditText housing_btn;

    /**
     * 添加客户
     */
    ImageView add;

    ArrayList<NewClassKehuModel> list = new ArrayList<NewClassKehuModel>();
    NewFromAdapter adapter;
    MyListView kehuxinxi;

    /**
     * 房源信息
     */
    private boolean IsFangyuan = true;

    /**
     * 客户信息
     */
    private boolean IsKehu = true;

    /**
     * 合同扫面
     */
    private boolean IShtsm = true;

    /**
     * 合同扫面件
     */
    LinearLayout phone;

    RelativeLayout phone_layout;

    /**
     * 房源信息
     */
    LinearLayout fangyuan, fangyuan_layout;

    /**
     * 客户信息
     */
    LinearLayout kehu, kehu_layout;

    ImageView rt1, rt2, rt1_p;

    /**
     * 证件类型
     */
    EditText zj_type;

    /* ---公用选择框--- */
    View view;
    PopupWindow popu;
    /**
     * 选中内容
     */
    String selectName;
    /**
     * 选中下标
     */
    int SelectID;
    List<String> listname;
    /* ---公用选择框--- */

    /**
     * 选择地址显示view
     */
    EditText addr_ed;

    /**
     * 自定义地址选择器
     */
    private SelectPicPopupWindow_Test popupWindow_Test;

    /**
     * 自定义时间控件
     */
    private Time_SelectPicPopupWindow time_SelectPicPopupWindow;

    /**
     * 选择时间显示view
     */
    EditText time_ed;

    /**
     * 选择地址
     */
    EditText select_address;

    /**
     * 邮编
     */
    EditText pePostcode_view;

    TextView title_main;

    ImageView back_btn;

    ArrayList<AddpirModel> ap;

    ArrayList<AddpirModel> ap2 = new ArrayList<AddpirModel>();

    /**
     * 合同扫面适配器
     */
    PhoneSelectAdapter padapter;

    /**
     * 商业首付
     */
    EditText s_first_pay2;

    /**
     * 商业按揭
     */
    EditText work_pay2;

    /**
     * 付款方式
     */
    EditText pay_type, et_fitment_pay_type;

    /**
     * 首付
     */
    EditText first_pay1;

    /**
     * 公积金按揭
     */
    EditText ggj_pay1;

    /**
     * 扫面列表grid
     */
    MyGridView grid_phone;

    /**
     * 一次性付款
     */
    LinearLayout onest_pay, fitment_once_pay, ll_fitment_pay_way, ll_fitment_price;

    /**
     * 组合贷款
     */
    View include_zuhedaikuan;

    /**
     * 组合贷款首付款应收日期
     */
    EditText shoufu_1;

    /**
     * 组合带看商业按揭款应收日期
     */
    EditText shangye_1;

    /**
     * 组合带看公积金按揭款应收日期
     */
    EditText gongjijin_1;

    /**
     * 商业贷款首付款应收日期
     */
    View include_shangyedaikuan, fitment_shangyedaikuan;

    /**
     * 商业贷款首付款应收日期
     */
    EditText shoufu_2;

    /**
     * 商业贷款商业按揭款应收日期
     */
    EditText shangye_2;

    /**
     * 公积金贷款
     */
    View include_gongjijindaikuan;

    /**
     * 公积金贷款首付款应收日期
     */
    EditText shoufu_3;

    /**
     * 公积金贷款公积金按揭应收日期
     */
    EditText gongjijin_3;

    /**
     * 组合首付
     */
    EditText zuhe_pay1s;

    /**
     * 组合商业按揭
     */
    EditText zuhe_pay2s;

    /**
     * 组合公积金按揭
     */
    EditText zuhe_pay3s;

    /**
     * 分期付款
     */
    View include_fenqifukuan, fitment_fenqifukuan;

    /**
     * 分期付款一期款
     */
    EditText pay_date_1;

    /**
     * 分期付款二期款
     */
    EditText pay_date_2;

    /**
     * 分期付款三期款
     */
    EditText pay_date_3;

    /**
     * 分期付款四期款
     */
    EditText pay_date_4;

    /**
     * 分期付款五期款
     */
    EditText pay_date_5;

    /**
     * 分期付款一期款应收日期
     */
    EditText fenqi_1;

    /**
     * 分期付款二期款应收日期
     */
    EditText fenqi_2;

    /**
     * 分期付款三期款应收日期
     */
    EditText fenqi_3;

    /**
     * 分期付款四期款应收日期
     */
    EditText fenqi_4;

    /**
     * 分期付款五期款应收日期
     */
    EditText fenqi_5;

    /**
     * 应收日期
     */
    EditText p_jjrmine;

    /**
     * 成交类型
     */
    EditText pad_type_fund;

    /**
     * 签约日期
     */
    EditText qianyue_time;

    // /** 经纪人 */
    // EditText p_jjr;
    /*-----------------------------------------------*/

    /**
     * 计价面积
     */
    EditText calculateArea_view;

    /**
     * 折前单价
     */
    EditText discountPrice_view;

    /**
     * 折前总价
     */
    EditText discountTotalPrice_view;

    /**
     * 客户姓名
     */
    EditText customerName_view;

    /**
     * 证件号码
     */
    EditText peDocumentNumber_view;

    /**
     * 手机号
     */
    EditText customerPhone_view;

    /**
     * 折扣金额
     */
    EditText discountAmount_view;

    /**
     * 折扣比例
     */
    EditText discountRate_view;

    /**
     * 折扣说明
     */
    EditText discountNote_view;

    /**
     * 签约单价
     */
    EditText contractPrice_view;

    /**
     * 合同金额
     */
    EditText contractAmount_view;

    /**
     * 当前百分比
     */
    TextView number1;

    /**
     * 浮动值百分比
     */
    TextView number2;

    View line_type_for_code;

    /**
     * 优惠原因
     */
    EditText youhui_view;

    /**
     * 折扣原因
     */
    LinearLayout is_code1;

    /**
     * 提示内容
     */
    LinearLayout is_code2;

    /**
     * 应收金额
     */
    EditText receivable_view;

    /**
     * 备注
     */
    EditText remark_view;

    /**
     * 提交审核
     */
    TextView reject_btn;

    /**
     * 保存
     */
    TextView is_sure;

    /**
     * 签约编号
     */
    EditText signedDepositCode_view;

    /*-----------------------------------------------*/

    LinearLayout discountAmount_all_view_linear;

    /**
     * 折后总价
     */
    EditText discountAmount_all_view;

    MyListView jj_list;

    ImageView open_icon;

    /**
     * 认筹认购类型 rc认筹 rg认购
     */
    private String activitytype;

    /**
     * 已收认筹或认购
     */
    private String realAmount;

    /**
     * 已收认筹 认购
     */
    LinearLayout realAmount_t1_lineas;

    LinearLayout reference_linear_layout;

    /**
     * 推荐人
     */
    EditText referenceName;

    ImageView more_referenceName;

    /**
     * 推荐人分佣比例
     */
    EditText referenceProportion;

    /**
     * 附件布局
     */
    LinearLayout annex_layout;

    /**
     * 附件列表
     */
    MyListView annexList_list;

    /**
     * 附件数量
     */
    TextView annexNum_view;

    /**
     * 合同金额与应收总金额不同的提示信息
     */
    String pointout;

    /**
     * 用于监听最外层布局高度，判断键盘弹出不展示保存和提交审核的底部菜单
     */
    RelativeLayout background_key;

    /**
     * 底部菜单布局
     */
    LinearLayout buttom_select;

    SwitchButton sb_fitment;

    GetHousesDetail houseDetail;

    /**
     * 装修款应收金额日期
     */
    EditText etFitmentReceivePrice, etFitmentReceiveDate;

    /**
     * 装修款已收金额
     */
    TextView tvFitmentReceivedPrice, tvFitmentUnreceivedPrice, tvFitmentPrice, tvTotalPrice;

    /**
     * 装修款分期
     */
    EditText etFitmentFirstPay, etFitmentSecondPay, etFitmentThirdPay, etFitmentFourthPay, etFitmentFifthPay;

    /**
     * 装修款按揭
     */
    EditText etFitmentHeadPay, etFitmentWorkPay;

    /**
     * 装修款应收日期
     */
    EditText etFitmentFirstDate, etFitmentSecondDate, etFitmentThirdDate, etFitmentFourthDate, etFitmentFifthDate,
            etFitmentHeadDate, etEtFitmentWorkDate;

    /**
     * 装修款分期、按揭已收未收
     */
    TextView tvFitmentFirstReceive, tvFitmentFirstUnreceive, tvFitmentSecondReceive, tvFitmentSecondUnreceive,
            tvFitmentFourthReceive, tvFitmentFourthUnreceive, tvFitmentThirdReceive, tvFitmentThirdUnreceive,
            tvFitmentFifthReceive, tvFitmentFifthUnreceive, tvFitmentHeadReceive, tvFitmentHeadUnreceive,
            tvFitmentWorkReceive, tvFitmentWorkUnreceive;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        IsVisibleStatusBar = false;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_signed);
        BaseActivity.activity = this;

        OpenType = getIntent().getStringExtra("OpenType");
        customerId = getIntent().getStringExtra("customerId");
        payDepositId = getIntent().getStringExtra("payDepositId");
        payDepositCode = getIntent().getStringExtra("payDepositCode");
        payDepositMoney = getIntent().getStringExtra("payDepositMoney");
        subscribeId = getIntent().getStringExtra("subscribeId");
        subscribeCode = getIntent().getStringExtra("subscribeCode");
        subscribeAmount = getIntent().getStringExtra("subscribeAmount");
        signId = getIntent().getStringExtra("signId");
        FrdID = getIntent().getStringExtra("FrdID");
        activitytype = getIntent().getStringExtra("activitytype");
        realAmount = getIntent().getStringExtra("realAmount");

        payDepositId = IsNullSetNone(payDepositId);
        payDepositCode = IsNullSetNone(payDepositCode);
        payDepositMoney = IsNullSetNone(payDepositMoney);
        subscribeId = IsNullSetNone(subscribeId);
        subscribeCode = IsNullSetNone(subscribeCode);
        subscribeAmount = IsNullSetNone(subscribeAmount);
        activitytype = IsNullSetNone(activitytype);

        houseDetail = (GetHousesDetail) getIntent().getSerializableExtra(NewSubscribeActivity.HOUSE_DETAIL);

        Log.v(TAG, "-----------OpenType:" + OpenType + "\n-----------customerId:" + customerId
                + "\n-----------payDepositId:" + payDepositId);
        Log.v(TAG, "-----------payDepositCode:" + payDepositCode + "\n-----------payDepositMoney:" + payDepositMoney
                + "\n-----------subscribeId:" + subscribeId);
        Log.v(TAG, "-----------subscribeCode:" + subscribeCode + "\n-----------subscribeAmount:" + subscribeAmount);

        Log.v(TAG, "activitytype:" + activitytype);

        ap2.clear();

        initView();
        initView2();

        findViewById(R.id.statusbar_bg).setVisibility(View.GONE);
        // SetRelativiLayoutPadding(R.id.main_head_top_rela);

        initBtn();
        setHouseDetail();

        qianyue_time.setText(EmmApplication.dataTime(EmmApplication.geTime(), "yyyy年MM月dd日"));
        if ("1".equals(OpenType)) {// 新增
            if (houseDetail == null) getCustomerDetail(customerId);
            getConsultantList(1);
        } else if ("5".equals(OpenType) || "6".equals(OpenType)) {
            if (houseDetail == null) getCustomerDetail(customerId);
            getConsultantList(1);
            housing_btn.setEnabled(false);
        } else {// 修改
            getConsultantList(7);
        }

        getDictionaryList();
    }

    private String IsNullSetNone(String str) {
        if (EmmApplication.isNull(str)) {
            return str;
        } else {
            return "";
        }
    }

    /**
     * <p>
     * <b>Title：</b> 初始化view
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:47:56
     */
    private void initView() {
        fitment_shangyedaikuan = findViewById(R.id.fitment_shangyedaikuan);
        etFitmentHeadPay = fitment_shangyedaikuan.findViewById(R.id.s_first_pay2);
        etFitmentWorkPay = fitment_shangyedaikuan.findViewById(R.id.work_pay2);
        etFitmentHeadDate = fitment_shangyedaikuan.findViewById(R.id.shoufu_2);
        etEtFitmentWorkDate = fitment_shangyedaikuan.findViewById(R.id.shangye_2);
        tvFitmentHeadReceive = fitment_shangyedaikuan.findViewById(R.id.sy_x_1s);
        tvFitmentHeadUnreceive = fitment_shangyedaikuan.findViewById(R.id.sy_x_2s);
        tvFitmentWorkReceive = fitment_shangyedaikuan.findViewById(R.id.sy_x_3s);
        tvFitmentWorkUnreceive = fitment_shangyedaikuan.findViewById(R.id.sy_x_4s);

        fitment_fenqifukuan = findViewById(R.id.fitment_fenqifukuan);
        etFitmentFirstPay = fitment_fenqifukuan.findViewById(R.id.pay_date_1);
        etFitmentSecondPay = fitment_fenqifukuan.findViewById(R.id.pay_date_2);
        etFitmentThirdPay = fitment_fenqifukuan.findViewById(R.id.pay_date_3);
        etFitmentFourthPay = fitment_fenqifukuan.findViewById(R.id.pay_date_4);
        etFitmentFifthPay = fitment_fenqifukuan.findViewById(R.id.pay_date_5);
        etFitmentFirstDate = fitment_fenqifukuan.findViewById(R.id.fenqi_1);
        etFitmentSecondDate = fitment_fenqifukuan.findViewById(R.id.fenqi_2);
        etFitmentThirdDate = fitment_fenqifukuan.findViewById(R.id.fenqi_3);
        etFitmentFourthDate = fitment_fenqifukuan.findViewById(R.id.fenqi_4);
        etFitmentFifthDate = fitment_fenqifukuan.findViewById(R.id.fenqi_5);
        tvFitmentFirstReceive = fitment_fenqifukuan.findViewById(R.id.fq_x_1s);
        tvFitmentFirstUnreceive = fitment_fenqifukuan.findViewById(R.id.fq_x_2s);
        tvFitmentSecondReceive = fitment_fenqifukuan.findViewById(R.id.fq_x_3s);
        tvFitmentSecondUnreceive = fitment_fenqifukuan.findViewById(R.id.fq_x_4s);
        tvFitmentThirdReceive = fitment_fenqifukuan.findViewById(R.id.fq_x_5s);
        tvFitmentThirdUnreceive = fitment_fenqifukuan.findViewById(R.id.fq_x_6s);
        tvFitmentFourthReceive = fitment_fenqifukuan.findViewById(R.id.fq_x_7s);
        tvFitmentFourthUnreceive = fitment_fenqifukuan.findViewById(R.id.fq_x_8s);
        tvFitmentFifthReceive = fitment_fenqifukuan.findViewById(R.id.fq_x_9s);
        tvFitmentFifthUnreceive = fitment_fenqifukuan.findViewById(R.id.fq_x_10s);

        etFitmentReceiveDate = (EditText) findViewById(R.id.et_fitment_receive_date);
        tvTotalPrice = (TextView) findViewById(R.id.tv_total_price);
        tvFitmentPrice = (TextView) findViewById(R.id.tv_fitment_price);
        tvFitmentReceivedPrice = (TextView) findViewById(R.id.tv_fitment_received);
        tvFitmentUnreceivedPrice = (TextView) findViewById(R.id.tv_fitment_unreceived);
        etFitmentReceivePrice = (EditText) findViewById(R.id.et_fitment_receive_price);
        ll_fitment_price = (LinearLayout) findViewById(R.id.ll_fitment_price);
        ll_fitment_pay_way = (LinearLayout) findViewById(R.id.ll_fitment_pay_way);
        fitment_once_pay = (LinearLayout) findViewById(R.id.fitment_once_pay);
        et_fitment_pay_type = (EditText) findViewById(R.id.et_fitment_pay_type);
        sb_fitment = (SwitchButton) findViewById(R.id.sb_fitment);
        housing_btn = (EditText) findViewById(R.id.housing_btn);
        add = (ImageView) findViewById(R.id.add);
        kehuxinxi = (MyListView) findViewById(R.id.kehuxinxi);
        fangyuan = (LinearLayout) findViewById(R.id.fangyuan);
        fangyuan_layout = (LinearLayout) findViewById(R.id.fangyuan_layout);
        rt1 = (ImageView) findViewById(R.id.rt1);
        kehu = (LinearLayout) findViewById(R.id.kehu);
        kehu_layout = (LinearLayout) findViewById(R.id.kehu_layout);
        rt2 = (ImageView) findViewById(R.id.rt2);
        phone = (LinearLayout) findViewById(R.id.phone);
        phone_layout = (RelativeLayout) findViewById(R.id.phone_layout);
        rt1_p = (ImageView) findViewById(R.id.rt1_p);
        zj_type = (EditText) findViewById(R.id.zj_type);
        select_address = (EditText) findViewById(R.id.select_address);
        title_main = (TextView) findViewById(R.id.title_main);
        if ("1".equals(OpenType) || "5".equals(OpenType) || "6".equals(OpenType)) {// 新增
            title_main.setText(getString(R.string.set_qy));
        } else {// 修改
            title_main.setText(getString(R.string.set_qy2));
        }
        back_btn = (ImageView) findViewById(R.id.back_btn);
        grid_phone = (MyGridView) findViewById(R.id.grid_phone);
        include_zuhedaikuan = findViewById(R.id.include_zuhedaikuan);
        shoufu_1 = (EditText) include_zuhedaikuan.findViewById(R.id.shoufu_1);
        shangye_1 = (EditText) include_zuhedaikuan.findViewById(R.id.shangye_1);
        gongjijin_1 = (EditText) include_zuhedaikuan.findViewById(R.id.gongjijin_1);
        zuhe_pay1s = (EditText) include_zuhedaikuan.findViewById(R.id.zuhe_pay1s);
        zuhe_pay2s = (EditText) include_zuhedaikuan.findViewById(R.id.zuhe_pay2s);
        zuhe_pay3s = (EditText) include_zuhedaikuan.findViewById(R.id.zuhe_pay3s);
        discountAmount_all_view = (EditText) findViewById(R.id.discountAmount_all_view);
        discountAmount_all_view_linear = (LinearLayout) findViewById(R.id.discountAmount_all_view_linear);

        include_shangyedaikuan = findViewById(R.id.include_shangyedaikuan);
        shoufu_2 = (EditText) include_shangyedaikuan.findViewById(R.id.shoufu_2);
        shangye_2 = (EditText) include_shangyedaikuan.findViewById(R.id.shangye_2);
        s_first_pay2 = (EditText) include_shangyedaikuan.findViewById(R.id.s_first_pay2);
        work_pay2 = (EditText) include_shangyedaikuan.findViewById(R.id.work_pay2);
        include_gongjijindaikuan = findViewById(R.id.include_gongjijindaikuan);
        shoufu_3 = (EditText) include_gongjijindaikuan.findViewById(R.id.shoufu_3);
        gongjijin_3 = (EditText) include_gongjijindaikuan.findViewById(R.id.gongjijin_3);
        include_fenqifukuan = findViewById(R.id.include_fenqifukuan);
        fenqi_1 = (EditText) include_fenqifukuan.findViewById(R.id.fenqi_1);
        fenqi_2 = (EditText) include_fenqifukuan.findViewById(R.id.fenqi_2);
        fenqi_3 = (EditText) include_fenqifukuan.findViewById(R.id.fenqi_3);
        fenqi_4 = (EditText) include_fenqifukuan.findViewById(R.id.fenqi_4);
        fenqi_5 = (EditText) include_fenqifukuan.findViewById(R.id.fenqi_5);
        pay_date_1 = (EditText) include_fenqifukuan.findViewById(R.id.pay_date_1);
        pay_date_2 = (EditText) include_fenqifukuan.findViewById(R.id.pay_date_2);
        pay_date_3 = (EditText) include_fenqifukuan.findViewById(R.id.pay_date_3);
        pay_date_4 = (EditText) include_fenqifukuan.findViewById(R.id.pay_date_4);
        pay_date_5 = (EditText) include_fenqifukuan.findViewById(R.id.pay_date_5);
        pay_type = (EditText) findViewById(R.id.pay_type);
        p_jjrmine = (EditText) findViewById(R.id.p_jjrmine);
        pad_type_fund = (EditText) findViewById(R.id.pad_type_fund);
        qianyue_time = (EditText) findViewById(R.id.qianyue_time);

        calculateArea_view = (EditText) findViewById(R.id.calculateArea_view);
        discountPrice_view = (EditText) findViewById(R.id.discountPrice_view);
        discountTotalPrice_view = (EditText) findViewById(R.id.discountTotalPrice_view);
        customerName_view = (EditText) findViewById(R.id.customerName_view);
        peDocumentNumber_view = (EditText) findViewById(R.id.peDocumentNumber_view);
        customerPhone_view = (EditText) findViewById(R.id.customerPhone_view);
        discountAmount_view = (EditText) findViewById(R.id.discountAmount_view);
        discountRate_view = (EditText) findViewById(R.id.discountRate_view);
        discountNote_view = (EditText) findViewById(R.id.discountNote_view);
        contractPrice_view = (EditText) findViewById(R.id.contractPrice_view);
        contractAmount_view = (EditText) findViewById(R.id.contractAmount_view);

        youhui_view = (EditText) findViewById(R.id.youhui_view);
        is_code1 = (LinearLayout) findViewById(R.id.is_code1);
        is_code2 = (LinearLayout) findViewById(R.id.is_code2);
        number1 = (TextView) findViewById(R.id.number1);
        number2 = (TextView) findViewById(R.id.number2);
        line_type_for_code = findViewById(R.id.line_type_for_code);

        receivable_view = (EditText) findViewById(R.id.receivable_view);
        remark_view = (EditText) findViewById(R.id.remark_view);
        reject_btn = (TextView) findViewById(R.id.reject_btn);
        is_sure = (TextView) findViewById(R.id.is_sure);
        onest_pay = (LinearLayout) findViewById(R.id.onest_pay);
        first_pay1 = (EditText) include_gongjijindaikuan.findViewById(R.id.first_pay1);
        ggj_pay1 = (EditText) include_gongjijindaikuan.findViewById(R.id.ggj_pay1);
        signedDepositCode_view = (EditText) findViewById(R.id.signedDepositCode_view);
        pePostcode_view = (EditText) findViewById(R.id.pePostcode_view);
        jj_list = (MyListView) findViewById(R.id.jj_list);
        open_icon = (ImageView) findViewById(R.id.open_icon);
        realAmount_t1_lineas = (LinearLayout) findViewById(R.id.realAmount_t1_lineas);
        lllines = findViewById(R.id.lllines);
        realAmount_t1 = (TextView) findViewById(R.id.realAmount_t1);
        realAmount_t2 = (EditText) findViewById(R.id.realAmount_t2);
        reference_linear_layout = (LinearLayout) findViewById(R.id.reference_linear_layout);
        referenceName = (EditText) findViewById(R.id.referenceName);
        more_referenceName = (ImageView) findViewById(R.id.more_referenceName);
        referenceProportion = (EditText) findViewById(R.id.referenceProportion);
        yc_x_1 = (TextView) findViewById(R.id.yc_x_1s);
        yc_x_2 = (TextView) findViewById(R.id.yc_x_2s);
        zuhe_w_1 = (TextView) findViewById(R.id.zuhe_w_1s);
        zuhe_w_2 = (TextView) findViewById(R.id.zuhe_w_2s);
        zuhe_w_3 = (TextView) findViewById(R.id.zuhe_w_3s);
        zuhe_w_4 = (TextView) findViewById(R.id.zuhe_w_4s);
        zuhe_w_5 = (TextView) findViewById(R.id.zuhe_w_5s);
        zuhe_w_6 = (TextView) findViewById(R.id.zuhe_w_6s);
        sy_x_1 = (TextView) findViewById(R.id.sy_x_1s);
        sy_x_2 = (TextView) findViewById(R.id.sy_x_2s);
        sy_x_3 = (TextView) findViewById(R.id.sy_x_3s);
        sy_x_4 = (TextView) findViewById(R.id.sy_x_4s);
        gjj_x_1 = (TextView) findViewById(R.id.gjj_x_1s);
        gjj_x_2 = (TextView) findViewById(R.id.gjj_x_2s);
        gjj_x_3 = (TextView) findViewById(R.id.gjj_x_3s);
        gjj_x_4 = (TextView) findViewById(R.id.gjj_x_4s);
        fq_x_1 = (TextView) findViewById(R.id.fq_x_1s);
        fq_x_2 = (TextView) findViewById(R.id.fq_x_2s);
        fq_x_3 = (TextView) findViewById(R.id.fq_x_3s);
        fq_x_4 = (TextView) findViewById(R.id.fq_x_4s);
        fq_x_5 = (TextView) findViewById(R.id.fq_x_5s);
        fq_x_6 = (TextView) findViewById(R.id.fq_x_6s);
        fq_x_7 = (TextView) findViewById(R.id.fq_x_7s);
        fq_x_8 = (TextView) findViewById(R.id.fq_x_8s);
        fq_x_9 = (TextView) findViewById(R.id.fq_x_9s);
        fq_x_10 = (TextView) findViewById(R.id.fq_x_10s);
        if (EmmApplication.isNull(activitytype)) {
            realAmount_t1_lineas.setVisibility(View.VISIBLE);
            lllines.setVisibility(View.VISIBLE);
            if ("rc".equals(activitytype)) {
                realAmount_t1.setText("已收认筹金");
            } else if ("rg".equals(activitytype)) {
                realAmount_t1.setText("已收认购金");
            }
            realAmount_t2.setText(realAmount);
        } else {
            realAmount_t1_lineas.setVisibility(View.GONE);
            lllines.setVisibility(View.GONE);
        }

        annex_layout = (LinearLayout) findViewById(R.id.annex_layout);
        annexList_list = (MyListView) findViewById(R.id.annexList_list);
        annexNum_view = (TextView) findViewById(R.id.annexNum_view);

        background_key = (RelativeLayout) findViewById(R.id.background_key);
        buttom_select = (LinearLayout) findViewById(R.id.buttom_select);
    }

    View lllines;
    TextView realAmount_t1;
    EditText realAmount_t2;

    private void setHouseDetail() {
        if (houseDetail != null) {
            housing_btn.setText(houseDetail.getHousesName(), null);
            calculateArea_view.setText(houseDetail.getBuildingArea(), null);
            discountPrice_view.setText(houseDetail.getBuildingPrice(), null);
            try {
                String price = new DecimalFormat("0.00").format(Double.parseDouble(houseDetail.getTotalAmount()) * 10000);
                discountTotalPrice_view.setText(price, null);
                discountAmount_all_view.setText(price, null);
            } catch (Exception e) {
                e.printStackTrace();
            }
            customerName_view.setFocusable(false);
            customerName_view.setFocusableInTouchMode(false);
            customerName_view.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivityForResult(new Intent(NewSignedActivity.this, CustomerListActivity.class), SELECT_CUSTOMER);
                }
            });
        }
    }

    /**
     * <p>
     * <b>Title：</b> 初始化经纪人list
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:48:40
     */
    private void setjjdate() {
        JJInfo jinfo = new JJInfo();
        jinfo.setName("" + EmmApplication.getUserName());
        jinfo.setNumber("100");
        jinfo.setPid(EmmApplication.getUserId());
        jjlist.add(jinfo);

        jjlist.clear();

        jjadapter = new JJAdapter(jjlist, NewSignedActivity.this, getconsultan.getConsultantList());
        jj_list.setAdapter(jjadapter);
        jjadapter.SetType(0);
    }

    JJAdapter jjadapter;

    ArrayList<JJInfo> jjlist = new ArrayList<NewSignedActivity.JJInfo>();

    public static class JJInfo {
        private String name;
        private String number;
        private String pid;

        public String getPid() {
            return pid;
        }

        public void setPid(String pid) {
            this.pid = pid;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }
    }

    /**
     * 0上限1 1上限3
     */
    private int typefound = 0;

    /**
     * <p>
     * <b>Title：</b> 初始化监听事件
     * </p>
     * <p>
     * <b>Description：</b> 2017年1月6日09:46:54 tangxin 修改
     * :用于监听最外层布局高度，判断键盘弹出不展示保存和提交审核的底部菜单
     * <p>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:48:59
     */
    private void initBtn() {
        contractAmount_view.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                double housePrice = 0, fitmentPrice = 0;
                try {
                    housePrice = Double.parseDouble(String.valueOf(s));
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                if (sb_fitment.isChecked()) {
                    try {
                        fitmentPrice = Double.parseDouble(tvFitmentPrice.getText().toString());
                    } catch (NumberFormatException e) {
                        e.printStackTrace();
                    }
                }
                double total = housePrice + fitmentPrice;
                tvTotalPrice.setText(total + "");
            }
        });

        etFitmentHeadDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentHeadDate);
            }
        });

        etEtFitmentWorkDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etEtFitmentWorkDate);
            }
        });


        etFitmentHeadPay.addTextChangedListener(new FenqiTextWatcher(tvFitmentHeadUnreceive));
        etFitmentWorkPay.addTextChangedListener(new FenqiTextWatcher(tvFitmentWorkUnreceive));

        etFitmentFirstDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentFirstDate);
            }
        });

        etFitmentSecondDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentSecondDate);
            }
        });

        etFitmentThirdDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentThirdDate);
            }
        });

        etFitmentFourthDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentFourthDate);
            }
        });

        etFitmentFifthDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentFifthDate);
            }
        });
        etFitmentFirstPay.addTextChangedListener(new CalculateTextWatcher(tvFitmentFirstUnreceive));
        etFitmentSecondPay.addTextChangedListener(new CalculateTextWatcher(tvFitmentSecondUnreceive));
        etFitmentThirdPay.addTextChangedListener(new CalculateTextWatcher(tvFitmentThirdUnreceive));
        etFitmentFourthPay.addTextChangedListener(new CalculateTextWatcher(tvFitmentFourthUnreceive));
        etFitmentFifthPay.addTextChangedListener(new CalculateTextWatcher(tvFitmentFifthUnreceive));

        etFitmentReceiveDate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(etFitmentReceiveDate);
            }
        });

        tvFitmentPrice.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                double fitmentPrice = 0, housePrice = 0;
                try {
                    fitmentPrice = Double.parseDouble(s.toString());
                    housePrice = Double.parseDouble(contractAmount_view.getText().toString());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                double totalPrice = fitmentPrice + housePrice;
                tvTotalPrice.setText(totalPrice + "元");
            }
        });

        etFitmentReceivePrice.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                double price = 0;
                try {
                    price = Double.parseDouble(String.valueOf(s));
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                tvFitmentUnreceivedPrice.setText(price + "元");
                tvFitmentPrice.setText(price + "");
            }
        });

        et_fitment_pay_type.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listname = new ArrayList<>();
                listname.addAll(Arrays.asList(PAY_TYPES));
                BottomSheet bottomSheet = new BottomSheet();
                bottomSheet.setData(listname);
                bottomSheet.setListener(new Function1<Integer, Unit>() {
                    @Override
                    public Unit invoke(Integer position) {
                        showPayInput(position);
                        et_fitment_pay_type.setText(listname.get(position));
                        return null;
                    }
                });
                bottomSheet.show(getSupportFragmentManager(), "fitment");
            }
        });

        sb_fitment.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                double fitmentPrice = 0, housePrice = 0, total;
                try {
                    housePrice = Double.parseDouble(contractAmount_view.getText().toString());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                try {
                    fitmentPrice = Double.parseDouble(tvFitmentPrice.getText().toString());
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                if (isChecked) {
                    et_fitment_pay_type.setText("一次性付款");
                    ll_fitment_price.setVisibility(View.VISIBLE);
                    ll_fitment_pay_way.setVisibility(View.VISIBLE);
                    fitment_once_pay.setVisibility(View.VISIBLE);
                    total = housePrice + fitmentPrice;
                    tvTotalPrice.setText(total + "元");
                } else {
                    ll_fitment_price.setVisibility(View.GONE);
                    ll_fitment_pay_way.setVisibility(View.GONE);
                    fitment_once_pay.setVisibility(View.GONE);
                    fitment_fenqifukuan.setVisibility(View.GONE);
                    fitment_shangyedaikuan.setVisibility(View.GONE);
                    tvTotalPrice.setText(housePrice + "元");
                }
            }
        });

        background_key.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                // 比较Activity根布局与当前布局的大小
                int heightDiff = background_key.getRootView().getHeight() - background_key.getHeight();
                if (heightDiff > 100) {
                    // 大小超过100时，一般为显示虚拟键盘事件
                    Log.v(TAG, "---------大于一百--键盘打开");
                    buttom_select.setVisibility(View.GONE);
                } else {
                    // 大小小于100时，为不显示虚拟键盘或虚拟键盘隐藏
                    Log.v(TAG, "---------小于一百--键盘关闭");
                    buttom_select.setVisibility(View.VISIBLE);
                }
            }
        });

        IsOpenOrClose(fangyuan_layout, IsFangyuan, rt1);
        IsOpenOrClose(kehu_layout, IsKehu, rt2);
        IsOpenOrClose(phone_layout, IShtsm, rt1_p);
        back_btn.setVisibility(View.VISIBLE);
        open_icon.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (EmmApplication.isNull(pad_type_fund.getText().toString().trim()) == false) {
                    EmmApplication.Ts("请选择成交类别");
                    return;
                }
                if (typefound == 0) {
                    if (jjlist.size() < 1) {
                        JJInfo jinfo = new JJInfo();
                        jinfo.setName("");
                        jinfo.setNumber("");
                        jjlist.add(jinfo);
                        if (jjadapter == null) {
                            setjjdate();
                        }
                        jjadapter.SetDate(jjlist);
                    } else {
                        EmmApplication.Ts("经纪人数量已达上限");
                    }
                } else {
                    if (jjlist.size() < 3) {
                        JJInfo jinfo = new JJInfo();
                        jinfo.setName("");
                        jinfo.setNumber("");
                        jjlist.add(jinfo);
                        if (jjadapter == null) {
                            setjjdate();
                        }
                        jjadapter.SetDate(jjlist);
                    } else {
                        EmmApplication.Ts("经纪人数量已达上限");
                    }
                }
            }
        });

        referenceProportion.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                double allprice = 0;
                for (int i = 0; i < jjlist.size(); i++) {
                    String str = (EmmApplication.isNull(jjlist.get(i).getNumber()) == true ? jjlist.get(i).getNumber()
                            : "0");
                    allprice += Double.valueOf(str).doubleValue();
                }
                allprice += Double.valueOf(EmmApplication.isNull(s.toString()) ? s.toString() : "0").doubleValue();
                if (allprice > 100) {
                    referenceProportion.setText(s.toString().substring(0, (s.toString().length() - 1)));
                    referenceProportion.setSelection(referenceProportion.getText().toString().trim().length());
                    EmmApplication.Ts("分佣比例总和不能大于100%");
                    return;
                }
                jjadapter.SetReferenceProportion(Double.valueOf(EmmApplication.isNull(s.toString()) ? s.toString() : "0")
                        .doubleValue());
            }
        });

        back_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        fangyuan.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoOpenOrClose(IsFangyuan);
            }
        });
        phone.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoHTSMOpenOrClose(IShtsm);
            }
        });
        kehu.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                DoKehuOpenOrClose(IsKehu);
            }
        });
        housing_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (houseDetail == null) {
                    EmmApplication.housinglist.clear();
                    EmmApplication.IsGet = true;
                    startActivity(new Intent(NewSignedActivity.this, HousingresourcesActivity.class));
                }
            }
        });
        is_sure.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if ("1".equals(OpenType) || "5".equals(OpenType) || "6".equals(OpenType)) {
                    Loading.hideDialogForLoading();
                    Loading.showDialogForLoading(NewSignedActivity.this, "正在保存...", false, true, 100000);
                    RecordTaskUpdate record = new RecordTaskUpdate("0", 0);
                    record.execute();
                } else {
                    Loading.hideDialogForLoading();
                    Loading.showDialogForLoading(NewSignedActivity.this, "正在保存...", false, true, 100000);
                    RecordTaskUpdate record = new RecordTaskUpdate("0", 1);
                    record.execute();
                }

            }
        });
        reject_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if ("1".equals(OpenType) || "5".equals(OpenType) || "6".equals(OpenType)) {
                    Loading.showDialogForLoading(NewSignedActivity.this, "正在提交...", false, true, 100000);
                    RecordTaskUpdate record = new RecordTaskUpdate("1", 0);
                    record.execute();
                } else {
                    Loading.showDialogForLoading(NewSignedActivity.this, "正在提交...", false, true, 100000);
                    RecordTaskUpdate record = new RecordTaskUpdate("1", 1);
                    record.execute();
                }
            }
        });
        adapter = new NewFromAdapter(NewSignedActivity.this, list);
        kehuxinxi.setAdapter(adapter);
        adapter.SetType(0);
        add.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (list.size() >= 3) {
                    EmmApplication.Ts("最多添加4位");
                } else {
                    NewClassKehuModel n = new NewClassKehuModel();
                    n.setNumber("" + (list.size() + 2));
                    list.add(n);
                    adapter.SetDate(list);
                }
            }
        });
        zj_type.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listname = new ArrayList<>();
                if (DocumentType != null) {
                    for (int i = 0; i < DocumentType.size(); i++) {
                        listname.add(DocumentType.get(i).getDictionaryName());
                    }
                    setSelectPoPu(listname, "证件类型", zj_type);
                } else {
                    PopuContent.poPu(NewSignedActivity.this, "证件类列表为空", false, 1);
                }
            }
        });
        peDocumentNumber_view.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if ("身份证".equals(zj_type.getText().toString().trim())) {
                        if (s.toString().length() > 18) {
                            peDocumentNumber_view.setText(s.toString().trim()
                                    .substring(0, s.toString().trim().length() - 1));
                            peDocumentNumber_view.setSelection(peDocumentNumber_view.getText().toString().trim()
                                    .length());
                        }
                    }
                }
            }
        });
        SetDate();
        padapter = new PhoneSelectAdapter(NewSignedActivity.this, ap, 1);
        grid_phone.setAdapter(padapter);
        grid_phone.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if ("1".equals(ap.get(position).getType())) {
                    ViewPagerActivity.postion = position;
                    ViewPagerActivity.sDrawables.clear();
                    for (int u = 0; u < ap.size(); u++) {
                        if ("1".equals(ap.get(u).getType())) {
                            if ("1".equals(ap.get(u).getIsnet())) {
                                ViewPagerActivity.sDrawables.add("file://" + ap.get(u).getPath());
                            } else {
                                ViewPagerActivity.sDrawables.add(ap.get(u).getPath());
                            }
                        }
                    }
                    Intent intent = new Intent(NewSignedActivity.this, ViewPagerActivity.class);
                    intent.putExtra("IsOpenDelete", 0);
                    startActivity(intent);
                }
            }
        });
        pay_type.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listname = new ArrayList<String>();
                listname.add("一次性付款");
                listname.add("组合贷款");
                listname.add("商业按揭");
                listname.add("公积金按揭");
                listname.add("分期付款");
                setSelectPoPu(listname, "付款方式", pay_type);
            }
        });
        pay_type.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                // 判断分类，设置不同的布局展示
                String str = s.toString().trim();
                onest_pay.setVisibility("一次性付款".equals(str) ? View.VISIBLE : View.GONE);
                include_zuhedaikuan.setVisibility("组合贷款".equals(str) ? View.VISIBLE : View.GONE);
                if ("商业贷款".equals(str)) {
                    include_shangyedaikuan.setVisibility(View.VISIBLE);
                } else if ("商业按揭".equals(str)) {
                    include_shangyedaikuan.setVisibility(View.VISIBLE);
                } else {
                    include_shangyedaikuan.setVisibility(View.GONE);
                }

                if ("公积金贷款".equals(str)) {
                    include_gongjijindaikuan.setVisibility(View.VISIBLE);
                } else if ("公积金按揭".equals(str)) {
                    include_gongjijindaikuan.setVisibility(View.VISIBLE);
                } else {
                    include_gongjijindaikuan.setVisibility(View.GONE);
                }

                include_fenqifukuan.setVisibility("分期付款".equals(str) ? View.VISIBLE : View.GONE);
            }
        });

        shoufu_1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(shoufu_1);
            }
        });

        shangye_1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(shangye_1);
            }
        });

        gongjijin_1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(gongjijin_1);
            }
        });

        shoufu_2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(shoufu_2);
            }
        });
        shangye_2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(shangye_2);
            }
        });
        shoufu_3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(shoufu_3);
            }
        });
        gongjijin_3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(gongjijin_3);
            }
        });
        fenqi_1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(fenqi_1);
            }
        });
        fenqi_2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(fenqi_2);
            }
        });
        fenqi_3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(fenqi_3);
            }
        });
        fenqi_4.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(fenqi_4);
            }
        });
        fenqi_5.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(fenqi_5);
            }
        });
        p_jjrmine.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(p_jjrmine);
            }
        });
        pad_type_fund.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listname = new ArrayList<String>();
                listname.add("推荐成交");
                listname.add("单独成交");
                listname.add("共同成交");
                setSelectPoPu(listname, "成交类别", pad_type_fund);
            }
        });
        pad_type_fund.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {

                if (null != s.toString()) {
                    if ("共同成交".equals(s.toString())) {
                        typefound = 1;
                        if (null != jjlist && jjlist.size() > 0) {
                            jjadapter.SetDate(jjlist);
                        } else {
                            NewSignedActivity.JJInfo n = new JJInfo();
                            jjlist = new ArrayList<NewSignedActivity.JJInfo>();
                            n.setName(EmmApplication.getUserName());
                            n.setNumber("100");
                            n.setPid(EmmApplication.getUserId());
                            jjlist.clear();
                            jjlist.add(n);
                            if (jjadapter == null) {
                                setjjdate();
                            }
                            jjadapter.SetDate(jjlist);
                        }
                    } else {
                        typefound = 0;
                        NewSignedActivity.JJInfo n = new JJInfo();
                        if (null != jjlist && jjlist.size() > 0) {
                            n = jjlist.get(0);
                            jjlist.clear();
                            if (EmmApplication.isNull(n.getName())) {
                            } else {
                                n.setName(EmmApplication.getUserName());
                                n.setNumber("100");
                                n.setPid(EmmApplication.getUserId());
                            }
                            jjlist.add(n);
                            if (jjadapter == null) {
                                setjjdate();
                            }
                            jjadapter.SetDate(jjlist);
                        } else {
                            jjlist = new ArrayList<NewSignedActivity.JJInfo>();
                            n.setName(EmmApplication.getUserName());
                            n.setNumber("100");
                            n.setPid(EmmApplication.getUserId());
                            jjlist.clear();
                            jjlist.add(n);
                            if (jjadapter == null) {
                                setjjdate();
                            }
                            jjadapter.SetDate(jjlist);
                        }
                    }

                    if ("推荐成交".equals(s.toString())) {
                        reference_linear_layout.setVisibility(View.VISIBLE);
                    } else {
                        reference_linear_layout.setVisibility(View.GONE);
                    }

                } else {
                    typefound = 0;
                }

            }
        });
        // pad_type_fund.setText("单独成交");
        qianyue_time.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                UpTimeSelect(qianyue_time);
            }
        });

        // 增加折扣率等计算
        discountAmount_view.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (PriceType == 0) {

                } else {
                    if (EmmApplication.isNull(s.toString())) {

                        if (s.toString().indexOf(".") >= 0) {
                            if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                                // 已重复输入
                                discountAmount_view.setText(discountAmount_view.getText().toString()
                                        .substring(0, discountAmount_view.getText().toString().length() - 1));
                                discountAmount_view.setSelection(discountAmount_view.getText().toString().length());
                            }
                        }

                        if (EmmApplication.isNull(FrdID)) {// 不为空，已选择房源
                            discountRate_view.setText("");
                            if (Double.valueOf(discountAmount_view.getText().toString().trim()).doubleValue() > (Double
                                    .valueOf(discountTotalPrice_view.getText().toString().trim()).doubleValue()
                                    // * 10000
                            )) {
                                EmmApplication.Ts("折扣金额不能大于折前总价");
                                try {
                                    discountAmount_view.setText(""
                                            + EmmApplication.drop2(""
                                            + (Double.valueOf(discountTotalPrice_view.getText().toString()
                                            .trim()).doubleValue()
                                            // * 10000
                                    )));
                                } catch (NullPointerException e) {
                                    Log.v(TAG, "折扣金额大于折前总价处重置展示异常");
                                }
                                return;
                            }
                            double str = (1 - (Double.valueOf(discountAmount_view.getText().toString().trim())
                                    .doubleValue() / (Double.valueOf(discountTotalPrice_view.getText().toString()
                                    .trim()).doubleValue()
                                    // * 10000
                            ))) * 100;

                            String numb = EmmApplication.drop2("" + str);
                            discountRate_view.setText(numb);
                            number1.setText(numb + "%");
                            Log.v(TAG, "Hdnumber:" + Hdnumber);
                            if (Double.valueOf(numb).doubleValue() < Double.valueOf(Hdnumber).doubleValue()) {
                                Log.v("警告", "折扣比例已低于浮动值比例" + Hdnumber + "%");
                                is_code2.setVisibility(View.VISIBLE);
                                is_code1.setVisibility(View.VISIBLE);
                                line_type_for_code.setVisibility(View.VISIBLE);
                                IsDis = true;
                            } else {
                                is_code2.setVisibility(View.GONE);
                                is_code1.setVisibility(View.GONE);
                                line_type_for_code.setVisibility(View.GONE);
                                IsDis = false;
                            }

                            double discountTotalPrice_ = (Double.valueOf(discountTotalPrice_view.getText().toString()
                                    .trim()).doubleValue()
                                    // * 10000
                            );
                            contractAmount_view.setText(EmmApplication.drop2(""
                                            + ((discountTotalPrice_ - Double.valueOf(
                                    discountAmount_view.getText().toString().trim()).doubleValue()))
                                    // / 10000
                            )
                                    + "");
                            contractPrice_view.setText(EmmApplication.drop2(""
                                    + ((Double.valueOf(contractAmount_view.getText().toString().trim()).doubleValue()
                                    // * 10000
                            ) / Double.valueOf(calculateArea_view.getText().toString().trim()).doubleValue())));
                        } else {
                            EmmApplication.Ts("请先选择房源");
                            EmmApplication.disKey(NewSignedActivity.this);
                            discountAmount_view.setText("");
                        }
                    }
                }
            }
        });

        discountAmount_all_view.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (EmmApplication.isNull(s.toString())) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            discountAmount_all_view.setText(discountAmount_all_view.getText().toString()
                                    .substring(0, discountAmount_all_view.getText().toString().length() - 1));
                            discountAmount_all_view.setSelection(discountAmount_all_view.getText().toString().length());
                        }
                    }
                    if (EmmApplication.isNull(FrdID)) {// 不为空，已选择房源

                        discountAmount_view.setText(""
                                + ((Double.valueOf(discountTotalPrice_view.getText().toString().trim()).doubleValue()
                                // * 10000
                        ) - Double.valueOf(discountAmount_all_view.getText().toString().trim()).doubleValue()));
                        discountRate_view.setText(EmmApplication.drop2(""
                                + (Double.valueOf(discountAmount_all_view.getText().toString().trim()).doubleValue()
                                / (Double.valueOf(discountTotalPrice_view.getText().toString().trim())
                                .doubleValue()
                                // * 10000
                        ) * 100)));
                        number1.setText(discountAmount_view.getText().toString() + "元");

                        if (Double.valueOf(discountAmount_all_view.getText().toString().trim()).doubleValue() < Double
                                .valueOf(Hdnumber).doubleValue()) {
                            Log.v("警告", "折扣比例已低于浮动值比例" + Hdnumber + "%");
                            is_code2.setVisibility(View.GONE);
                            is_code1.setVisibility(View.GONE);
                            line_type_for_code.setVisibility(View.GONE);
                            IsDis = true;
                        } else {
                            is_code2.setVisibility(View.GONE);
                            is_code1.setVisibility(View.GONE);
                            line_type_for_code.setVisibility(View.GONE);
                            IsDis = false;
                        }

                        if (Double.valueOf(discountAmount_all_view.getText().toString().trim()).doubleValue() <= 0) {
                            contractAmount_view.setText(discountTotalPrice_view.getText().toString());
                            contractPrice_view.setText(discountPrice_view.getText().toString());
                        } else {
                            contractAmount_view.setText(EmmApplication.drop2(""
                                    + (Double.valueOf(discountAmount_all_view.getText().toString().trim())
                                    .doubleValue()
                                    // / 10000
                            )));
                            contractPrice_view.setText(EmmApplication.drop2(""
                                    + ((Double.valueOf(contractAmount_view.getText().toString().trim()).doubleValue()
                                    // * 10000
                            ) / Double.valueOf(calculateArea_view.getText().toString().trim()).doubleValue())));
                        }

                    } else {
                        EmmApplication.Ts("请先选择房源");
                        EmmApplication.disKey(NewSignedActivity.this);
                        discountAmount_all_view.setText("");
                    }
                } else {
                    discountRate_view.setText("0");
                    discountAmount_view.setText("0");
                    number1.setText("0%");
                    contractAmount_view.setText(discountTotalPrice_view.getText().toString().trim());
                    contractPrice_view.setText(discountPrice_view.getText().toString().trim());
                }
            }
        });

        more_referenceName.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                List<String> listname = new ArrayList<String>();
                if (null == getRecommendCustomerListHander
                        || null == getRecommendCustomerListHander.getRecommendCustomerList()) {
                    return;
                }
                for (int i = 0; i < getRecommendCustomerListHander.getRecommendCustomerList().size(); i++) {
                    listname.add(getRecommendCustomerListHander.getRecommendCustomerList().get(i).getCustomerName());
                }
                if (listname.size() <= 0) {
                    EmmApplication.Ts("当前没有可选客户");
                    return;
                } else {
                    setSelectPoPu(listname, "客户", referenceName);
                }
            }
        });

    }

    private class FenqiTextWatcher implements TextWatcher {

        TextView textView;

        FenqiTextWatcher(TextView textView) {
            this.textView = textView;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            textView.setText(String.valueOf(s) + "元");
            double head = 0, work = 0, total = 0;
            String headPay = etFitmentHeadPay.getText().toString();
            String workPay = etFitmentWorkPay.getText().toString();
            try {
                head = Double.parseDouble(headPay.isEmpty() ? "0" : headPay);
                work = Double.parseDouble(workPay.isEmpty() ? "0" : workPay);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            total = head + work;
            tvFitmentPrice.setText(total + "");
        }
    }

    private class CalculateTextWatcher implements TextWatcher {

        TextView textView;

        CalculateTextWatcher(TextView textView) {
            this.textView = textView;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            textView.setText(String.valueOf(s) + "元");
            double first = 0, second = 0, third = 0, fourth = 0, fifth = 0, total = 0;
            String firstPay = etFitmentFirstPay.getText().toString();
            String secondPay = etFitmentSecondPay.getText().toString();
            String thirdPay = etFitmentThirdPay.getText().toString();
            String fourthPay = etFitmentFourthPay.getText().toString();
            String fifthPay = etFitmentFifthPay.getText().toString();
            try {
                first = Double.parseDouble(firstPay.isEmpty() ? "0" : firstPay);
                second = Double.parseDouble(secondPay.isEmpty() ? "0" : secondPay);
                third = Double.parseDouble(thirdPay.isEmpty() ? "0" : thirdPay);
                fourth = Double.parseDouble(fourthPay.isEmpty() ? "0" : fourthPay);
                fifth = Double.parseDouble(fifthPay.isEmpty() ? "0" : fifthPay);
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
            total = first + second + third + fourth + fifth;
            tvFitmentPrice.setText(total + "");
        }
    }

    private void showPayInput(int position) {
        fitment_once_pay.setVisibility(View.GONE);
        fitment_fenqifukuan.setVisibility(View.GONE);
        fitment_shangyedaikuan.setVisibility(View.GONE);
        switch (position) {
            case 0:                          //一次性付款
                fitment_once_pay.setVisibility(View.VISIBLE);
                break;
            case 1:                          //分期付款
                fitment_fenqifukuan.setVisibility(View.VISIBLE);
                break;
            case 2:                          //商业按揭
                fitment_shangyedaikuan.setVisibility(View.VISIBLE);
                break;
            default:
                break;
        }
    }

    private void SetDropNumber(final EditText ed) {
        ed.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (s.toString().indexOf(".") >= 0) {
                    if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                        // 已重复输入
                        ed.setText(ed.getText().toString().substring(0, ed.getText().toString().length() - 1));
                        ed.setSelection(ed.getText().toString().length());
                    }
                }
            }
        });
    }

    public static class dealCategoryList {// （成交类别列表）
        private String relationAgentId;// 关联经纪人ID String(20) 关联经纪人ID
        private String proportionCommission;// 分佣比例 String(19) 分佣比例

        public String getRelationAgentId() {
            return relationAgentId;
        }

        public void setRelationAgentId(String relationAgentId) {
            this.relationAgentId = relationAgentId;
        }

        public String getProportionCommission() {
            return proportionCommission;
        }

        public void setProportionCommission(String proportionCommission) {
            this.proportionCommission = proportionCommission;
        }
    }

    /**
     * 查询置业顾问列表数据源
     */
    GetConsultantList getconsultan;

    /**
     * 选择经纪人下标,默认-1为自己
     */
    private int agentId = -1;

    /**
     * <p>
     * <b>Title：</b> 查询置业顾问列表
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param type no->1
     * @author tangxin
     * @date 2016年12月7日 下午3:50:03
     */
    private void getConsultantList(final int type) {
        EmmApplication.updateUrl("getConsultantList");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("projectId", EmmApplication.getProjectID());
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getConsultantList-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
                getRecommendCustomerListHander(type);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.showDialogForLoading(NewSignedActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v("置业顾问content", content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }
                getRecommendCustomerListHander(type);
                getconsultan = JSONObject.parseObject(resData.toString(), GetConsultantList.class);
                if ("1".equals(getconsultan.getResult())) {
                    Log.v("获取成功", "");
                    if (getconsultan != null && getconsultan.getConsultantList() != null) {
                    } else {
                        EmmApplication.Ts("当前没有置业顾问");
                    }
                } else {
                    try {
                        EmmApplication.Ts(getconsultan.getErrorMsg().toString());

                        Log.v("获取失败", "errorCode:" + getconsultan.getErrorCode().toString() + "errorMsg:"
                                + getconsultan.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("查询置业顾问", "错误信息获取空指针异常");
                    }
                }
            }
        });
    }

    GetRecommendCustomerListHander getRecommendCustomerListHander;

    private void getRecommendCustomerListHander(final int type) {
        EmmApplication.updateUrl("getRecommendCustomerListHander");
        Map<String, String> map = new HashMap<String, String>();
        map.put("userId", EmmApplication.getUserId());
        map.put("resourcesCode", "menu_0006_0001");
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("projectId", EmmApplication.getProjectID());
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getRecommendCustomerListHander-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.hideDialogForLoading();
                Loading.showDialogForLoading(NewSignedActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v("置业顾问content", content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }
                setjjdate();
                if ("6".equals(OpenType)) {
                    String DealCategory = getIntent().getStringExtra("DealCategory");
                    pad_type_fund.setText(DealCategory);
                    String PaymentMethod = getIntent().getStringExtra("PaymentMethod");
                    pay_type.setText(PaymentMethod);

                    if (null != EmmApplication.dealCategoryList && EmmApplication.dealCategoryList.size() > 0) {
                        jjlist.clear();
                        for (int i = 0; i < EmmApplication.dealCategoryList.size(); i++) {
                            com.emm.yixun.mobile.ui.signed.NewSignedActivity.JJInfo jinfo = new com.emm.yixun.mobile.ui.signed.NewSignedActivity.JJInfo();
                            jinfo.setName(EmmApplication.dealCategoryList.get(i).getRelationAgentName());
                            jinfo.setNumber(EmmApplication.dealCategoryList.get(i).getProportionCommission());
                            jinfo.setPid(EmmApplication.dealCategoryList.get(i).getRelationAgentId());
                            jjlist.add(jinfo);
                        }
                        ArrayList<GetConsultantList.ConsultantList> consultantList = new ArrayList<ConsultantList>();
                        jjadapter = new JJAdapter(jjlist, NewSignedActivity.this, consultantList);
                        jj_list.setAdapter(jjadapter);
                        jjadapter.SetType(0);
                    }

                    if ("推荐成交".equals(DealCategory)) {
                        reference_linear_layout.setVisibility(View.VISIBLE);
                        referenceName.setText(getIntent().getStringExtra("ReferenceName"));
                        referenceProportion.setText(EmmApplication
                                .drop2(getIntent().getStringExtra("referenceProportion")));
                    } else {
                        reference_linear_layout.setVisibility(View.GONE);
                    }

                }
                if (type == 7) {
                    try {
                        SetDataView();
                    } catch (NullPointerException e) {
                        Log.v(TAG, "数据填充空指针：" + e.getMessage());
                    }
                }
                getRecommendCustomerListHander = JSONObject.parseObject(resData.toString(),
                        GetRecommendCustomerListHander.class);
                if ("1".equals(getRecommendCustomerListHander.getResult())) {
                    Log.v("获取成功", "");
                } else {
                    Log.v("获取失败", "");
                }
            }
        });
    }

    /**
     * <p>
     * <b>Title：</b> 选项框
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param listname
     * @param title
     * @param ed
     * @param type     type=0.普通，type=1选择经纪人
     * @author tangxin
     * @date 2016年12月7日 下午3:50:41
     */
    @SuppressLint("WrongConstant")
    public void setSelectPoPu(final List<String> listname, String title, final EditText ed, final int type) {
        view = LayoutInflater.from(NewSignedActivity.this).inflate(R.layout.popu_zp, null);
        popu = new PopupWindow(view, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
                android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
        popu.setFocusable(true);
        // EmmApplication.setNumberLog(NewSignedActivity.this, 0.5f);//
        // 改变popupwindow范围外的屏幕亮度
        popu.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popu.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popu.showAtLocation(view, Gravity.BOTTOM, 0, 0);
        popu.showAsDropDown(view, 0, 0);
        popu.setFocusable(true);
        popu.setOutsideTouchable(true);
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    popu.dismiss();
                    EmmApplication.setLog(NewSignedActivity.this);
                }
                return false;
            }
        });
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
            }
        });

        PickerView select_pick = (PickerView) view.findViewById(R.id.select_pick);

        selectName = listname.get(0);

        TextView shuerbtn = (TextView) view.findViewById(R.id.shuerbtn);
        RelativeLayout relative_all = (RelativeLayout) view.findViewById(R.id.relative_all);

        ImageView dis_btn = (ImageView) view.findViewById(R.id.dis_btn);
        dis_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
            }
        });
        TextView title_select = (TextView) view.findViewById(R.id.title_select);

        title_select.setText(title);

        select_pick.setData(listname);
        select_pick.setOnSelectListener(new onSelectListener() {
            @Override
            public void onSelect(String text, int id) {
                selectName = text;
                SelectID = id;
                if (type == 1) {
                    agentId = id;
                }
            }
        });
        select_pick.setSelected(0);
        shuerbtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 确定
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
                ed.setText(selectName);
            }
        });
        relative_all.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }

    /**
     * <p>
     * <b>Title：</b> 调用时间选择器
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param ed
     * @author tangxin
     * @date 2016年12月7日 下午3:51:07
     */
    private void UpTimeSelect(EditText ed) {
        time_ed = ed;
        // 调用时间选择器
        time_SelectPicPopupWindow = new Time_SelectPicPopupWindow(NewSignedActivity.this, keyListener, 0, GetDate(ed));
        time_SelectPicPopupWindow.showAtLocation(title_main, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
    }

    private Date GetDate(EditText view) {
        if (null != view.getText().toString().trim() && !"".equals(view.getText().toString().trim())
                && !"null".equals(view.getText().toString().trim())) {
            DateFormat fmt = new SimpleDateFormat("yyyy年MM月dd日");
            Date date = null;
            try {
                date = fmt.parse(view.getText().toString().trim());
            } catch (ParseException e) {
                date = new Date(System.currentTimeMillis());
                e.printStackTrace();
            }
            return date;
        } else {
            return new Date(System.currentTimeMillis());
        }
    }

    /**
     * <p>
     * <b>Title：</b> 添加默认数据
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:52:00
     */
    private void SetDate() {
        ap = new ArrayList<AddpirModel>();
        AddpirModel a = new AddpirModel();
        a.setIsnet("1");
        a.setType("2");
        a.setPath("");
        ap.add(a);
    }

    /**
     * <p>
     * <b>Title：</b> 判断各展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param view
     * @param bl
     * @param view2
     * @author tangxin
     * @date 2016年12月7日 下午3:52:12
     */
    private void IsOpenOrClose(View view, boolean bl, ImageView view2) {
        if (bl) {
            view.setVisibility(View.VISIBLE);
            view2.setImageResource(R.drawable.j_bottom);
        } else {
            view.setVisibility(View.GONE);
            view2.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的房源模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午3:52:19
     */
    private void DoOpenOrClose(boolean bl) {
        if (!bl) {
            IsFangyuan = true;
            fangyuan_layout.setVisibility(View.VISIBLE);
            rt1.setImageResource(R.drawable.j_bottom);
        } else {
            IsFangyuan = false;
            fangyuan_layout.setVisibility(View.GONE);
            rt1.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的客户信息模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午3:52:27
     */
    private void DoKehuOpenOrClose(boolean bl) {
        if (!bl) {
            IsKehu = true;
            kehu_layout.setVisibility(View.VISIBLE);
            rt2.setImageResource(R.drawable.j_bottom);
        } else {
            IsKehu = false;
            kehu_layout.setVisibility(View.GONE);
            rt2.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * <p>
     * <b>Title：</b> 判断操作中的房源模块的展开状况
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param bl
     * @author tangxin
     * @date 2016年12月7日 下午3:52:36
     */
    private void DoHTSMOpenOrClose(boolean bl) {
        if (!bl) {
            IShtsm = true;
            phone_layout.setVisibility(View.VISIBLE);
            rt1_p.setImageResource(R.drawable.j_bottom);
        } else {
            IShtsm = false;
            phone_layout.setVisibility(View.GONE);
            rt1_p.setImageResource(R.drawable.j_top);
        }
    }

    /**
     * 0 底价；1 折扣 默认底价
     */
    private int PriceType = 0;

    @Override
    protected void onResume() {
        super.onResume();
        BaseActivity.activity = this;
        if (EmmApplication.IsGet) {
            EmmApplication.IsGet = false;

            if (EmmApplication.housinglist != null && EmmApplication.housinglist.size() > 0) {

                String floorType = EmmApplication.housinglist.get(0).getFloorType();
                if (EmmApplication.isNull(floorType)) {
                    PriceType = Integer.valueOf(floorType).intValue();
                } else {
                    PriceType = 0;
                }

                housing_btn.setText(EmmApplication.housinglist.get(0).getRoomName());
                FrdID = EmmApplication.isNull(EmmApplication.housinglist.get(0).getRoomId()) ? EmmApplication.housinglist.get(0)
                        .getRoomId() : "";
                calculateArea_view
                        .setText(EmmApplication.isNull(EmmApplication.room.getCalculateArea()) == true ? EmmApplication.room
                                .getCalculateArea() : "0");
                discountPrice_view
                        .setText(EmmApplication.isNull(EmmApplication.room.getDiscountPrice()) == true ? EmmApplication.room
                                .getDiscountPrice() : "0");
                discountTotalPrice_view
                        .setText(EmmApplication.isNull(EmmApplication.room.getDiscountTotalPrice()) == true ? EmmApplication.room
                                .getDiscountTotalPrice() : "0");
                if (PriceType == 1) {
                    discountAmount_all_view_linear.setVisibility(View.GONE);
                    Hdnumber = EmmApplication.isNull(EmmApplication.housinglist.get(0).getDiscountRate()) ? EmmApplication.housinglist
                            .get(0).getDiscountRate() : "0";
                    Hdprice = EmmApplication.isNull(EmmApplication.housinglist.get(0).getDiscountAmount()) ? EmmApplication.housinglist
                            .get(0).getDiscountAmount() : "";
                    number2.setText(Hdnumber + "%");
                    // 折扣不默认为空，需要根据房源带出显示
                    // if (EmmApplication.IsNewSelect) {
                    // EmmApplication.IsNewSelect = false;
                    // discountAmount_view.setText("");
                    // } else {
                    discountAmount_view.setText(EmmApplication.drop2(Hdprice));
                    // }

                    discountAmount_view.setEnabled(true);
                } else {
                    discountAmount_view.setEnabled(false);
                    discountAmount_all_view_linear.setVisibility(View.VISIBLE);
                    Hdnumber = EmmApplication.isNull(EmmApplication.housinglist.get(0).getDiscountRate()) ? EmmApplication.housinglist
                            .get(0).getDiscountRate() : "0";
                    number2.setText(Hdnumber + "元");
                    if (EmmApplication.IsNewSelect) {
                        EmmApplication.IsNewSelect = false;
                        discountAmount_all_view.setText("");
                    } else {
                        if (EmmApplication.isNull(EmmApplication.room.getDiscountTotalPrice())
                                && EmmApplication.isNull(EmmApplication.room.getDiscountAmount())) {
                            double number = (Double.valueOf(EmmApplication.room.getDiscountTotalPrice()).doubleValue()
                                    // * 10000
                            )
                                    - Double.valueOf(EmmApplication.room.getDiscountAmount()).doubleValue();
                            // Hdnumber = ""
                            // + ((Double.valueOf(Hdnumber).doubleValue() / 100)
                            // * (Double.valueOf(
                            // EmmApplication.room.getDiscountTotalPrice()).doubleValue()
                            // * 10000));
                            discountAmount_all_view.setText(EmmApplication.drop2("" + number));
                            Log.v(TAG, Hdnumber);
                        } else {
                            discountAmount_all_view.setText("");
                        }
                    }
                }
            }
        }

        SetImage();

        IntentFilter filter = new IntentFilter();
        filter.addAction("open_Image_popu");
        registerReceiver(mBroadcastReceiver, filter);
    }

    private void SetImage() {

        // 0不变 1删除
        if (null != EmmApplication.pir || EmmApplication.pir.size() > 0) {
            if (null != ap) {
                // ap.clear();
            } else {
                ap = new ArrayList<AddpirModel>();
            }
            if (EmmApplication.IsCreate) {// 是否新建，需要穿件一个按钮
                EmmApplication.IsCreate = false;
                ap.clear();
                AddpirModel a = new AddpirModel();
                a.setIsnet("1");
                a.setType("2");
                a.setPath("");
                ap.add(a);
            }
            for (int i = 0; i < EmmApplication.pir.size(); i++) {
                int y = 0;
                for (int n = 0; n < ap.size(); n++) {
                    if (EmmApplication.pir.get(i).sourcePath.equals(ap.get(n).getPath())) {
                        y++;
                    }
                }
                if (y > 0) {
                    Log.v(TAG, "已存在，不添加");
                } else {
                    AddpirModel a = new AddpirModel();
                    a.setIsnet(EmmApplication.pir.get(i).type);
                    a.setType("1");
                    a.setPath(EmmApplication.pir.get(i).sourcePath);
                    ap.add(0, a);
                }
            }

            padapter.SetDate(ap);
        }
    }

    /**
     * 广播监听方法
     */
    private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals("open_Image_popu")) {
                popu();
            }
        }
    };

    @Override
    protected void onDestroy() {
        unregisterReceiver(mBroadcastReceiver);
        super.onDestroy();
        EmmApplication.IsLoadingFromList = false;// 解除限制
        EmmApplication.pir.clear();
    }

    /**
     * <p>
     * <b>Title：</b> 选项框
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param listname
     * @param title
     * @param ed
     * @author tangxin
     * @date 2016年12月7日 下午3:53:21
     */
    @SuppressLint("WrongConstant")
    public void setSelectPoPu(final List<String> listname, String title, final EditText ed) {
        view = LayoutInflater.from(NewSignedActivity.this).inflate(R.layout.popu_zp, null);
        popu = new PopupWindow(view, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
                android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
        popu.setFocusable(true);
        // EmmApplication.setNumberLog(NewSignedActivity.this, 0.5f);//
        // 改变popupwindow范围外的屏幕亮度
        popu.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popu.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popu.showAtLocation(view, Gravity.BOTTOM, 0, 0);
        popu.showAsDropDown(view, 0, 0);
        popu.setFocusable(true);
        popu.setOutsideTouchable(true);
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    popu.dismiss();
                    EmmApplication.setLog(NewSignedActivity.this);
                }
                return false;
            }
        });
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
            }
        });

        PickerView select_pick = (PickerView) view.findViewById(R.id.select_pick);

        selectName = listname.get(0);

        TextView shuerbtn = (TextView) view.findViewById(R.id.shuerbtn);
        RelativeLayout relative_all = (RelativeLayout) view.findViewById(R.id.relative_all);

        ImageView dis_btn = (ImageView) view.findViewById(R.id.dis_btn);
        dis_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
            }
        });
        TextView title_select = (TextView) view.findViewById(R.id.title_select);

        title_select.setText(title);

        select_pick.setData(listname);
        select_pick.setOnSelectListener(new onSelectListener() {
            @Override
            public void onSelect(String text, int id) {
                selectName = text;
                SelectID = id;
            }
        });
        select_pick.setSelected(0);
        shuerbtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // 确定
                popu.dismiss();
                EmmApplication.setLog(NewSignedActivity.this);
                ed.setText(selectName);
            }
        });
        relative_all.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }

    OnClickListener keyListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.imageView1:
                    time_SelectPicPopupWindow.dismiss();
                    time_SelectPicPopupWindow.Aprils.clear();
                    time_SelectPicPopupWindow.Years.clear();
                    time_SelectPicPopupWindow.Days.clear();

                    SimpleDateFormat formats = new SimpleDateFormat("yyyy年MM月dd日");
                    Calendar c = Calendar.getInstance();
                    try {
                        c.setTime(formats.parse(time_SelectPicPopupWindow.getLanguage()
                                + time_SelectPicPopupWindow.getType_One() + time_SelectPicPopupWindow.getType()));
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }

                    Date endDate = c.getTime();
                    String str = formats.format(endDate);
                    Log.w(TAG, "str:" + str);
                    time_ed.setText(str);
                    break;
                default:
                    break;
            }
        }
    };

    OnClickListener keyListener2 = new OnClickListener() {
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.imageView1:
                    if (TextUtils.isEmpty(popupWindow_Test.getType()) || TextUtils.isEmpty(popupWindow_Test.getType_One())) {
                        EmmApplication.T("亲，您选择的地址有误，请重新选择");
                    } else {
                        addr_ed.setText(popupWindow_Test.getLanguage() + popupWindow_Test.getType()
                                + popupWindow_Test.getType_One());
                        EmmApplication.areaIds = popupWindow_Test.getareaId_one() + "|" + popupWindow_Test.getareaId_two()
                                + "|" + popupWindow_Test.getareaId_three();
                    }
                    Log.w("areaIds:", EmmApplication.areaIds);
                    popupWindow_Test.dismiss();
                    break;
                default:
                    break;
            }
        }

        ;
    };

    /**
     * 界面提示
     */
    @SuppressLint("HandlerLeak")
    Handler h = new Handler() {
        public void handleMessage(android.os.Message msg) {

            if (msg.what == 1) {
                EmmApplication.Ts("请添加合同扫面");
                disloading();
            } else if (msg.what == 2) {
                EmmApplication.Ts("请选择签约房源");
                disloading();
            } else if (msg.what == 3) {
                EmmApplication.Ts("请输入客户姓名");
                disloading();
            } else if (msg.what == 4) {
                EmmApplication.Ts("请选择证件类型");
                disloading();
            } else if (msg.what == 5) {
                EmmApplication.Ts("请输入证件号");
                disloading();
            } else if (msg.what == 6) {
                EmmApplication.Ts("请输入手机号码");
                disloading();
            } else if (msg.what == 7) {
                EmmApplication.Ts("请输入优惠说明");
                disloading();
            } else if (msg.what == 8) {
                EmmApplication.Ts("请选择经纪人");
                disloading();
            } else if (msg.what == 9) {
                EmmApplication.Ts("请选择邮寄地址");
                disloading();
            } else if (msg.what == 10) {
                EmmApplication.Ts("请填写邮编");
                disloading();
            } else if (msg.what == 11) {
                EmmApplication.Ts("存在家庭成员名称未填");
                disloading();
            } else if (msg.what == 12) {
                EmmApplication.Ts("存在家庭成员证件类型未选");
                disloading();
            } else if (msg.what == 13) {
                EmmApplication.Ts("存在家庭成员证件号未填");
                disloading();
            } else if (msg.what == 14) {
                EmmApplication.Ts("请填写应收金额 ");
                disloading();
            } else if (msg.what == 15) {
                EmmApplication.Ts("请选择应收日期");
                disloading();
            } else if (msg.what == 16) {
                EmmApplication.Ts("请填写一期款");
                disloading();
            } else if (msg.what == 17) {
                EmmApplication.Ts("请填写二期款");
                disloading();
            } else if (msg.what == 18) {
                EmmApplication.Ts("请填写三期款");
                disloading();
            } else if (msg.what == 19) {
                EmmApplication.Ts("请填写四期款");
                disloading();
            } else if (msg.what == 20) {
                EmmApplication.Ts("请填写五期款");
                disloading();
            } else if (msg.what == 21) {
                EmmApplication.Ts("请选择一期款应收日期");
                disloading();
            } else if (msg.what == 22) {
                EmmApplication.Ts("请选择二期款应收日期");
                disloading();
            } else if (msg.what == 23) {
                EmmApplication.Ts("请选择三期款应收日期");
                disloading();
            } else if (msg.what == 24) {
                EmmApplication.Ts("请选择四期款应收日期");
                disloading();
            } else if (msg.what == 25) {
                EmmApplication.Ts("请选择五期款应收日期");
                disloading();
            } else if (msg.what == 26) {
                EmmApplication.Ts("请填写首付金额");
                disloading();
            } else if (msg.what == 27) {
                EmmApplication.Ts("请填写商业按揭金额");
                disloading();
            } else if (msg.what == 28) {
                EmmApplication.Ts("请选择首付应收日期");
                disloading();
            } else if (msg.what == 29) {
                EmmApplication.Ts("请选择商业按揭应收日期");
                disloading();
            } else if (msg.what == 30) {
                EmmApplication.Ts("请填写公积金按揭金额");
                disloading();
            } else if (msg.what == 31) {
                EmmApplication.Ts("请选择公积金按揭应收日期");
                disloading();
            } else if (msg.what == 32) {
                EmmApplication.Ts("请填写经纪人信息");
                disloading();
            } else if (msg.what == 33) {
                EmmApplication.Ts("请添加经纪人信息");
                disloading();
            } else if (msg.what == 34) {
                EmmApplication.Ts("分佣至少需要两名经纪人");
                disloading();
            } else if (msg.what == 35) {
                EmmApplication.Ts("请填写正确的身份证号码");
                disloading();
            } else if (msg.what == 36) {
                EmmApplication.T("请填写证件号码");
                disloading();
            } else if (msg.what == 37) {
                EmmApplication.T("请填写推荐人");
                disloading();
            } else if (msg.what == 38) {
                EmmApplication.T("请填写客户分佣比例");
                disloading();
            } else if (msg.what == 41) {
                EmmApplication.Ts("请选择付款方式");
                disloading();
            } else if (msg.what == 42) {
                EmmApplication.Ts("请选择成交类型");
                disloading();
            } else if (msg.what == 43) {
                PopuContent.poPu(activity, pointout, false, 0);
                disloading();
            } else if (msg.what == 109) {
                EmmApplication.Ts("分拥比例不等于100%，请重新输入");
                disloading();
            }
        }

        ;
    };

    AddSigned addsig;

    /**
     * <p>
     * <b>Title：</b> 新增签约接口
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param contentList_
     * @param auditStatus  审核状态：0、待提交；1、待审核
     * @param type         0 新增 1修改
     * @author tangxin
     * @date 2016年12月7日 下午3:54:50
     */
    private void AddSigned(ArrayList<ImageListInfo> contentList_, String auditStatus, int type) {
        Map<String, Object> map = new HashMap<String, Object>();
        if (type == 0) {
            EmmApplication.updateUrl("addSigned");
        } else {
            EmmApplication.updateUrl("editSigned");
            map.put("signedId", signId);
        }
        map.put("customerId", customerId);
        map.put("payDepositId", EmmApplication.isNull(payDepositId) ? payDepositId : "");
        map.put("payDepositCode", EmmApplication.isNull(payDepositCode) ? payDepositCode : "");
        map.put("payDepositMoney", EmmApplication.isNull(payDepositMoney) ? payDepositMoney : "");
        map.put("subscribeId", EmmApplication.isNull(subscribeId) ? subscribeId : "");
        map.put("projectId", EmmApplication.getProjectID());
        map.put("subscribeCode", EmmApplication.isNull(subscribeCode) ? subscribeCode : "");
        map.put("subscribeAmount", EmmApplication.isNull(subscribeAmount) ? subscribeAmount : "");

        if (sb_fitment.isChecked()) {
            map.put("decorationMoney", tvFitmentPrice.getText().toString());
            List<PaymentMethodListinfo> payments = new ArrayList<>();
            switch (et_fitment_pay_type.getText().toString()) {
                case "一次性付款":
                    PaymentMethodListinfo info = new PaymentMethodListinfo();
                    info.setPayContent("一次性付款");
                    String receivable = etFitmentReceivePrice.getText().toString();
                    if (TextUtils.isEmpty(receivable)) {
                        h.sendEmptyMessage(14);
                        return;
                    } else {
                        info.setReceivable(receivable);
                    }
                    String receivableDate = etFitmentReceiveDate.getText().toString();
                    if (TextUtils.isEmpty(receivableDate)) {
                        h.sendEmptyMessage(15);
                        return;
                    } else {
                        info.setReceivableDate(EmmApplication.replaceTime(receivableDate));
                    }
                    payments.add(info);
                    map.put("decorationPaymentMethod", "1");
                    break;
                case "分期付款":
                    PaymentMethodListinfo method1 = new PaymentMethodListinfo();
                    String pay1 = etFitmentFirstPay.getText().toString();
                    if (TextUtils.isEmpty(pay1)) {
                        h.sendEmptyMessage(16);
                        return;
                    } else {
                        method1.setPayContent("一期款");
                        method1.setReceivable(pay1);
                    }
                    String date1 = etFitmentFirstDate.getText().toString();
                    if (TextUtils.isEmpty(date1)) {
                        h.sendEmptyMessage(21);
                        return;
                    } else {
                        method1.setReceivableDate(EmmApplication.replaceTime(date1));
                    }
                    payments.add(method1);

                    String pay2 = etFitmentSecondPay.getText().toString();
                    if (!TextUtils.isEmpty(pay2)) {
                        PaymentMethodListinfo method2 = new PaymentMethodListinfo();
                        method2.setPayContent("二期款");
                        method2.setReceivable(pay2);
                        String date2 = etFitmentSecondDate.getText().toString();
                        if (TextUtils.isEmpty(date2)) {
                            h.sendEmptyMessage(22);
                            return;
                        } else {
                            method2.setReceivableDate(EmmApplication.replaceTime(date2));
                            payments.add(method2);
                        }
                    }

                    String pay3 = etFitmentThirdPay.getText().toString();
                    if (!TextUtils.isEmpty(pay3)) {
                        PaymentMethodListinfo method3 = new PaymentMethodListinfo();
                        method3.setPayContent("三期款");
                        method3.setReceivable(pay3);
                        String date3 = etFitmentThirdDate.getText().toString();
                        if (TextUtils.isEmpty(date3)) {
                            h.sendEmptyMessage(23);
                            return;
                        } else {
                            method3.setReceivableDate(EmmApplication.replaceTime(date3));
                            payments.add(method3);
                        }
                    }

                    String pay4 = etFitmentFourthPay.getText().toString();
                    if (!TextUtils.isEmpty(pay4)) {
                        PaymentMethodListinfo method4 = new PaymentMethodListinfo();
                        method4.setPayContent("四期款");
                        method4.setReceivable(pay4);
                        String date4 = etFitmentFourthDate.getText().toString();
                        if (TextUtils.isEmpty(date4)) {
                            h.sendEmptyMessage(24);
                            return;
                        } else {
                            method4.setReceivableDate(EmmApplication.replaceTime(date4));
                            payments.add(method4);
                        }
                    }

                    String pay5 = etFitmentFifthPay.getText().toString();
                    if (!TextUtils.isEmpty(pay5)) {
                        PaymentMethodListinfo method5 = new PaymentMethodListinfo();
                        method5.setPayContent("五期款");
                        method5.setReceivable(pay5);
                        String date5 = etFitmentFifthDate.getText().toString();
                        if (TextUtils.isEmpty(date5)) {
                            h.sendEmptyMessage(25);
                            return;
                        } else {
                            method5.setReceivableDate(EmmApplication.replaceTime(date5));
                            payments.add(method5);
                        }
                    }
                    map.put("decorationPaymentMethod", "2");
                    break;
                case "商业按揭":
                    PaymentMethodListinfo head = new PaymentMethodListinfo();
                    head.setPayContent("首付款");
                    String headPay = etFitmentHeadPay.getText().toString();
                    if (TextUtils.isEmpty(headPay)) {
                        h.sendEmptyMessage(26);
                        return;
                    } else {
                        head.setReceivable(headPay);
                    }
                    String headDate = etFitmentHeadDate.getText().toString();
                    if (TextUtils.isEmpty(headDate)) {
                        h.sendEmptyMessage(28);
                        return;
                    } else {
                        head.setReceivableDate(EmmApplication.replaceTime(headDate));
                    }
                    payments.add(head);

                    PaymentMethodListinfo work = new PaymentMethodListinfo();
                    work.setPayContent("商业按揭");
                    String workPay = etFitmentWorkPay.getText().toString();
                    if (TextUtils.isEmpty(workPay)) {
                        h.sendEmptyMessage(27);
                        return;
                    } else {
                        work.setReceivable(workPay);
                    }
                    String workDate = etEtFitmentWorkDate.getText().toString();
                    if (TextUtils.isEmpty(workDate)) {
                        h.sendEmptyMessage(29);
                        return;
                    } else {
                        work.setReceivableDate(EmmApplication.replaceTime(workDate));
                    }
                    payments.add(work);
                    map.put("decorationPaymentMethod", "3");
                    break;
                default:
                    break;
            }
            map.put("decorationPaymentMethodList", payments);
        }

        if (0 == PriceType) {
            map.put("discountAfterAmount", discountAmount_all_view.getText().toString().trim());
        }

        if (EmmApplication.isNull(housing_btn.getText().toString().trim())) {
            map.put("signedHouses", FrdID);
        } else {
            h.sendEmptyMessage(2);
            return;
        }
        map.put("calculateArea", calculateArea_view.getText().toString().trim());
        map.put("discountPrice", discountPrice_view.getText().toString().trim());
        map.put("discountTotalPrice", discountTotalPrice_view.getText().toString());

        if (EmmApplication.isNull(customerName_view.getText().toString().trim())) {
            map.put("memberName", customerName_view.getText().toString().trim());
        } else {
            h.sendEmptyMessage(3);
            return;
        }

        Log.v(TAG, "身份证" + zj_type.getText().toString().trim());
        if (EmmApplication.isNull(zj_type.getText().toString().trim())) {
            if (null != DocumentType && DocumentType.size() > 0) {
                for (int i = 0; i < DocumentType.size(); i++) {
                    if (zj_type.getText().toString().trim().equals(DocumentType.get(i).getDictionaryName())) {
                        map.put("documentType", DocumentType.get(i).getDictionaryId());
                    }
                }
            } else {
                PopuContent.poPu(NewSignedActivity.this, "证件类型数据获取失败", false, 0);
                return;
            }
        } else {
            h.sendEmptyMessage(4);
            return;
        }

        if (EmmApplication.isNull(peDocumentNumber_view.getText().toString().trim())) {
            if ("身份证".equals(zj_type.getText().toString().trim())) {
                if (EmmApplication.isTrueCode(peDocumentNumber_view.getText().toString().trim())) {
                    map.put("documentNumber", peDocumentNumber_view.getText().toString().trim());
                } else {
                    h.sendEmptyMessage(35);
                    return;
                }
            } else {
                map.put("documentNumber", peDocumentNumber_view.getText().toString().trim());
            }
        } else {
            h.sendEmptyMessage(36);
            return;
        }

        // 手机号码
        if (EmmApplication.isNull(customerPhone_view.getText().toString().trim())) {
            map.put("mobile", customerPhone_view.getText().toString().trim());
        } else {
            h.sendEmptyMessage(6);
            return;
        }

        map.put("discountAmount", discountAmount_view.getText().toString().trim());

        map.put("discountRate", discountRate_view.getText().toString().trim());

        map.put("discountNote", discountNote_view.getText().toString().trim());

        map.put("contractPrice", contractPrice_view.getText().toString().trim());

        map.put("contractAmount", contractAmount_view.getText().toString().trim());
        // contractAmount 合同金额
        if ("1".equals("" + PriceType)) {
            if (IsDis) {
                if (EmmApplication.isNull(youhui_view.getText().toString().trim())) {
                    map.put("preferentialReasons", youhui_view.getText().toString().trim());
                } else {
                    h.sendEmptyMessage(7);
                    return;
                }
            }
        }

        map.put("floorType", PriceType);
        if (0 == PriceType) {
            if (IsDis && EmmApplication.isNull(discountAmount_all_view.getText().toString().trim())) {// 需要折扣审批
                map.put("discountApproval", "1");
            } else {
                map.put("discountApproval", "0");
            }
        } else {
            if (IsDis && EmmApplication.isNull(discountAmount_view.getText().toString().trim())) {// 需要折扣审批
                map.put("discountApproval", "1");
            } else {
                map.put("discountApproval", "0");
            }
        }
        // dealCategory 成交类别
        if ("推荐成交".equals(pad_type_fund.getText().toString().trim())) {// dealCategory
            // 成交类别
            map.put("dealCategory", "1");

            String referenceName_id = "";
            for (int i = 0; i < getRecommendCustomerListHander.getRecommendCustomerList().size(); i++) {
                if (referenceName.getText().toString()
                        .equals(getRecommendCustomerListHander.getRecommendCustomerList().get(i).getCustomerName())) {
                    referenceName_id = getRecommendCustomerListHander.getRecommendCustomerList().get(i).getCustomerId();
                }
            }
            map.put("referenceId", referenceName_id);
            if (EmmApplication.isNull(referenceName.getText().toString().trim())) {
                map.put("referenceName", referenceName.getText().toString().trim());
            } else {
                h.sendEmptyMessage(37);
                return;
            }

            if (EmmApplication.isNull(referenceProportion.getText().toString().trim())) {
                map.put("referenceProportion", referenceProportion.getText().toString().trim());
            } else {
                h.sendEmptyMessage(38);
                return;
            }

        } else if ("单独成交".equals(pad_type_fund.getText().toString().trim())) {
            map.put("dealCategory", "2");
        } else if ("共同成交".equals(pad_type_fund.getText().toString().trim())) {
            map.put("dealCategory", "3");
        } else {
            h.sendEmptyMessage(42);
            return;
        }

        ArrayList<dealCategoryList> dealcategorylist = new ArrayList<NewSignedActivity.dealCategoryList>();

        for (int p = 0; p < jjlist.size(); p++) {
            dealCategoryList d = new dealCategoryList();
            if (EmmApplication.isNull(jjlist.get(p).getNumber()) == false) {
                h.sendEmptyMessage(32);
                return;
            }
            d.setProportionCommission(jjlist.get(p).getNumber());
            if (EmmApplication.isNull(jjlist.get(p).getPid()) == false) {
                h.sendEmptyMessage(32);
                return;
            }
            d.setRelationAgentId(jjlist.get(p).getPid());
            dealcategorylist.add(d);
        }

        if (EmmApplication.isNull(pad_type_fund.getText().toString().trim())) {
            if (dealcategorylist.size() <= 0) {
                h.sendEmptyMessage(33);
                return;
            }
            if ("共同成交".equals(pad_type_fund.getText().toString().trim())) {
                if (dealcategorylist.size() < 2) {
                    h.sendEmptyMessage(34);
                    return;
                }
                double allnumber = 0;
                for (int i = 0; i < dealcategorylist.size(); i++) {
                    allnumber += Double.valueOf(dealcategorylist.get(i).getProportionCommission()).doubleValue();
                }
                if (allnumber < 100) {
                    h.sendEmptyMessage(109);
                    return;
                }
            }
            if ("推荐成交".equals(pad_type_fund.getText().toString().trim())
                    && Double.valueOf(dealcategorylist.get(0).getProportionCommission()).doubleValue() < 100) {
                h.sendEmptyMessage(109);
                return;
            }
            if ("单独成交".equals(pad_type_fund.getText().toString().trim())
                    && Double.valueOf(dealcategorylist.get(0).getProportionCommission()).doubleValue() < 100) {
                h.sendEmptyMessage(109);
                return;
            }
            map.put("dealCategoryList", dealcategorylist);
        }

        // 邮寄地址
        if (EmmApplication.isNull(select_address.getText().toString().trim())) {
            map.put("mailPost", select_address.getText().toString().trim());
        }

        // 邮编
        if (EmmApplication.isNull(pePostcode_view.getText().toString().trim())) {
            map.put("postcode", pePostcode_view.getText().toString().trim());
        }

        map.put("type", "2");

        map.put("category", "3");

        // qianyue_time -->签约日期
        // signedDate 签约日期 String(19) 签约日期格式：yyyy-MM-dd N
        map.put("signedDate", EmmApplication.replaceTime(qianyue_time.getText().toString().trim()));
        // -------------------------------------------------------------------------------------------------------------------

        // imageList合同【图片列表】
        // headType 上传头像后缀名
        // signedUrl 签约拍照图片（图片文件流）
        map.put("imageList", contentList_);

        // remark 备注
        map.put("remark", remark_view.getText().toString().trim());

        // auditStatus 审核状态 0、待提交；1、待审核
        map.put("auditStatus", auditStatus);

        ArrayList<CustomerFamilyListInfo> customerFamilyList = new ArrayList<CustomerFamilyListInfo>();

        for (int i = 0; i < list.size(); i++) {
            CustomerFamilyListInfo f = new CustomerFamilyListInfo();
            if (!EmmApplication.isNull(list.get(i).getName())) {
                h.sendEmptyMessage(11);
                // break;
                return;
            }
            if (!EmmApplication.isNull(list.get(i).getType())) {
                h.sendEmptyMessage(12);
                // break;
                return;
            }
            if (!EmmApplication.isNull(list.get(i).getCode())) {
                h.sendEmptyMessage(13);
                return;
            }
            f.setDocumentNumber(list.get(i).getCode());
            f.setMemberName(list.get(i).getName());
            String stn = list.get(i).getType();
            if (null != DocumentType && DocumentType.size() > 0) {
                for (int y = 0; y < DocumentType.size(); y++) {
                    if (stn.equals(DocumentType.get(y).getDictionaryName())) {
                        f.setDocumentType(DocumentType.get(y).getDictionaryId());
                    }
                }
            } else {
                PopuContent.poPu(NewSignedActivity.this, "证件类型数据获取失败", false, 0);
                return;
            }
            customerFamilyList.add(f);
        }
        map.put("customerFamilyList", customerFamilyList);

        ArrayList<PaymentMethodListinfo> paymentMethodList = new ArrayList<PaymentMethodListinfo>();
        if ("一次性付款".equals(pay_type.getText().toString().trim())) {// paymentMethod
            // 付款方式
            map.put("paymentMethod", "1");
            PaymentMethodListinfo p = new PaymentMethodListinfo();
            p.setPayContent("一次性付款");
            if (EmmApplication.isNull(receivable_view.getText().toString().trim())) {
                p.setReceivable(receivable_view.getText().toString().trim());
            } else {
                h.sendEmptyMessage(14);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(p_jjrmine.getText().toString().trim()))) {
                p.setReceivableDate(EmmApplication.replaceTime(p_jjrmine.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(15);
                return;
            }
            paymentMethodList.add(p);
        } else if ("分期付款".equals(pay_type.getText().toString().trim())) {
            map.put("paymentMethod", "2");

            PaymentMethodListinfo p = new PaymentMethodListinfo();
            p.setPayContent("一期款");
            if (EmmApplication.isNull(pay_date_1.getText().toString().trim())) {
                p.setReceivable(pay_date_1.getText().toString().trim());
            } else {
                h.sendEmptyMessage(16);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(fenqi_1.getText().toString().trim()))) {
                p.setReceivableDate(EmmApplication.replaceTime(fenqi_1.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(21);
                return;
            }
            paymentMethodList.add(p);

            if (EmmApplication.isNull(pay_date_2.getText().toString().trim())) {
                PaymentMethodListinfo p2 = new PaymentMethodListinfo();
                p2.setPayContent("二期款");
                p2.setReceivable(pay_date_2.getText().toString().trim());
                if (EmmApplication.isNull(EmmApplication.replaceTime(fenqi_2.getText().toString().trim()))) {
                    p2.setReceivableDate(EmmApplication.replaceTime(fenqi_2.getText().toString().trim()));
                } else {
                    h.sendEmptyMessage(22);
                    return;
                }
                paymentMethodList.add(p2);
            } else {
                // h.sendEmptyMessage(17);
                // return;
            }

            if (EmmApplication.isNull(pay_date_3.getText().toString().trim())) {
                PaymentMethodListinfo p3 = new PaymentMethodListinfo();
                p3.setPayContent("三期款");
                p3.setReceivable(pay_date_3.getText().toString().trim());
                if (EmmApplication.isNull(EmmApplication.replaceTime(fenqi_3.getText().toString().trim()))) {
                    p3.setReceivableDate(EmmApplication.replaceTime(fenqi_3.getText().toString().trim()));
                } else {
                    h.sendEmptyMessage(23);
                    return;
                }
                paymentMethodList.add(p3);
            } else {
                // h.sendEmptyMessage(18);
                // return;
            }

            if (EmmApplication.isNull(pay_date_4.getText().toString().trim())) {
                PaymentMethodListinfo p4 = new PaymentMethodListinfo();
                p4.setPayContent("四期款");
                p4.setReceivable(pay_date_4.getText().toString().trim());
                if (EmmApplication.isNull(EmmApplication.replaceTime(fenqi_4.getText().toString().trim()))) {
                    p4.setReceivableDate(EmmApplication.replaceTime(fenqi_4.getText().toString().trim()));
                } else {
                    h.sendEmptyMessage(24);
                    return;
                }
                paymentMethodList.add(p4);
            } else {
                // h.sendEmptyMessage(19);
                // return;
            }

            if (EmmApplication.isNull(pay_date_5.getText().toString().trim())) {
                PaymentMethodListinfo p5 = new PaymentMethodListinfo();
                p5.setPayContent("五期款");
                p5.setReceivable(pay_date_5.getText().toString().trim());
                if (EmmApplication.isNull(EmmApplication.replaceTime(fenqi_5.getText().toString().trim()))) {
                    p5.setReceivableDate(EmmApplication.replaceTime(fenqi_5.getText().toString().trim()));
                } else {
                    h.sendEmptyMessage(25);
                    return;
                }
                paymentMethodList.add(p5);
            } else {
                // h.sendEmptyMessage(20);
                // return;
            }

        } else if ("商业按揭".equals(pay_type.getText().toString().trim())
                || "商业贷款".equals(pay_type.getText().toString().trim())) {
            map.put("paymentMethod", "3");
            PaymentMethodListinfo p = new PaymentMethodListinfo();
            p.setPayContent("首付款");
            if (EmmApplication.isNull(s_first_pay2.getText().toString().trim())) {
                p.setReceivable(s_first_pay2.getText().toString().trim());
            } else {
                h.sendEmptyMessage(26);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(shoufu_2.getText().toString().trim()))) {
                p.setReceivableDate(EmmApplication.replaceTime(shoufu_2.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(28);
                return;
            }
            paymentMethodList.add(p);

            PaymentMethodListinfo p2 = new PaymentMethodListinfo();
            p2.setPayContent("按揭银行");
            if (EmmApplication.isNull(work_pay2.getText().toString().trim())) {
                p2.setReceivable(work_pay2.getText().toString().trim());
            } else {
                h.sendEmptyMessage(27);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(shangye_2.getText().toString().trim()))) {
                p2.setReceivableDate(EmmApplication.replaceTime(shangye_2.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(29);
                return;
            }
            paymentMethodList.add(p2);

        } else if ("公积金按揭".equals(pay_type.getText().toString().trim())
                || "公积金贷款".equals(pay_type.getText().toString().trim())) {
            map.put("paymentMethod", "4");
            PaymentMethodListinfo p = new PaymentMethodListinfo();
            p.setPayContent("首付款");
            if (EmmApplication.isNull(first_pay1.getText().toString().trim())) {
                p.setReceivable(first_pay1.getText().toString().trim());
            } else {
                h.sendEmptyMessage(26);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(shoufu_3.getText().toString().trim()))) {
                p.setReceivableDate(EmmApplication.replaceTime(shoufu_3.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(28);
                return;
            }
            paymentMethodList.add(p);

            PaymentMethodListinfo p2 = new PaymentMethodListinfo();
            p2.setPayContent("公积金");

            if (EmmApplication.isNull(ggj_pay1.getText().toString().trim())) {
                p2.setReceivable(ggj_pay1.getText().toString().trim());
            } else {
                h.sendEmptyMessage(30);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(gongjijin_3.getText().toString().trim()))) {
                p2.setReceivableDate(EmmApplication.replaceTime(gongjijin_3.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(31);
                return;
            }
            paymentMethodList.add(p2);
        } else if ("组合贷款".equals(pay_type.getText().toString().trim())) {
            map.put("paymentMethod", "5");

            PaymentMethodListinfo p = new PaymentMethodListinfo();
            p.setPayContent("首付款");
            if (EmmApplication.isNull(zuhe_pay1s.getText().toString().trim())) {
                p.setReceivable(zuhe_pay1s.getText().toString().trim());
            } else {
                h.sendEmptyMessage(26);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(shoufu_1.getText().toString().trim()))) {
                p.setReceivableDate(EmmApplication.replaceTime(shoufu_1.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(28);
                return;
            }
            paymentMethodList.add(p);

            PaymentMethodListinfo p2 = new PaymentMethodListinfo();
            p2.setPayContent("按揭银行");

            if (EmmApplication.isNull(zuhe_pay2s.getText().toString().trim())) {
                p2.setReceivable(zuhe_pay2s.getText().toString().trim());
            } else {
                h.sendEmptyMessage(27);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(shangye_1.getText().toString().trim()))) {
                p2.setReceivableDate(EmmApplication.replaceTime(shangye_1.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(29);
                return;
            }
            paymentMethodList.add(p2);

            PaymentMethodListinfo p3 = new PaymentMethodListinfo();
            p3.setPayContent("公积金");
            if (EmmApplication.isNull(zuhe_pay3s.getText().toString().trim())) {
                p3.setReceivable(zuhe_pay3s.getText().toString().trim());
            } else {
                h.sendEmptyMessage(30);
                return;
            }
            if (EmmApplication.isNull(EmmApplication.replaceTime(gongjijin_1.getText().toString().trim()))) {
                p3.setReceivableDate(EmmApplication.replaceTime(gongjijin_1.getText().toString().trim()));
            } else {
                h.sendEmptyMessage(31);
                return;
            }
            paymentMethodList.add(p3);
        } else {
            h.sendEmptyMessage(41);
            return;
        }

        /* 添加校验合同金额以及应收金额是否相等 */

        // 所有付款类型金额总和
        double allPayMentMethodPrice = 0;
        // 合同金额（通过签约房源必填校验，此处需要校验是否为空）,单位为万元，需要换算成元
        double contractAmountPrice = Double.valueOf(
                EmmApplication.isNull(contractAmount_view.getText().toString()) ? contractAmount_view.getText().toString()
                        : "0").doubleValue()
                // * 10000
                ;
        Log.v(TAG, "contractAmountPrice:" + contractAmountPrice);

        // 遍历求出应付金额总和
        for (int i = 0; i < paymentMethodList.size(); i++) {
            allPayMentMethodPrice += Double.valueOf(
                    EmmApplication.isNull(paymentMethodList.get(i).getReceivable()) ? paymentMethodList.get(i)
                            .getReceivable() : "0").doubleValue();
        }
        Log.v(TAG, "allPayMentMethodPrice:" + allPayMentMethodPrice);

        // 应收总金额不等于合同金额，校验不通过
        if (allPayMentMethodPrice != contractAmountPrice) {
            pointout = pay_type.getText().toString().trim() + "的总应收金额不等于合同金额";
            h.sendEmptyMessage(43);
            return;
        }

        map.put("paymentMethodList", paymentMethodList);

        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("signedCode", signedDepositCode_view.getText().toString().trim());

        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        String jsonstr = new Gson().toJson(paramsMap);
//        JSONObject json = new JSONObject(paramsMap);
//        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("addSigned-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
                handler.sendEmptyMessage(5);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                handler.sendEmptyMessage(5);
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                handler.sendEmptyMessage(6);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                Loading.hideDialogForLoading();
                if (content == null) {
                    return;
                }

                handler.sendEmptyMessage(5);

                Log.v("content", "content=>" + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                addsig = JSONObject.parseObject(resData.toString(), AddSigned.class);

                if ("1".equals(addsig.getResult())) {
                    Log.v("获取成功", "");
                    // 发送广播，告知刷新界面
                    if ("1".equals(OpenType)) {
                        handler.sendEmptyMessage(1);
                    } else {
                        handler.sendEmptyMessage(2);
                    }
                    EmmApplication.pir.clear();
                    finish();
                } else {
                    handler.sendEmptyMessage(3);
                    Log.v("获取失败", "errorCode:" + addsig.getErrorCode().toString() + "errorMsg:"
                            + addsig.getErrorMsg().toString());
                }
            }
        });
    }

    /**
     * 5 true 6 false
     */
    @SuppressLint("HandlerLeak")
    Handler handler = new Handler() {
        public void handleMessage(android.os.Message msg) {
            if (msg.what == 1) {
                EmmApplication.Ts("新增签约成功");
                sendBroadcast(new Intent(EmmApplication.NEW_ON_CS_UB_SC_RI_DETAILS));
                sendBroadcast(new Intent(EmmApplication.NEW_ON_CREATE_FROM_LIST));
                sendBroadcast(new Intent(EmmApplication.NEW_ON_CREATE_FROM));
                EmmApplication.IS_RELOAD_DETAILS = true;
            }
            if (msg.what == 2) {
                EmmApplication.Ts("修改签约成功");
                sendBroadcast(new Intent(EmmApplication.NEW_ON_CREATE_FROM));
                sendBroadcast(new Intent(EmmApplication.ON_CREATE_SIGNED_ACTIVITY));
                EmmApplication.IsReload = 3;
            }
            if (msg.what == 3) {
                EmmApplication.Ts(addsig.getErrorMsg().toString());
            }
            if (msg.what == 5) {
                is_sure.setEnabled(true);
                reject_btn.setEnabled(true);
            }
            if (msg.what == 6) {
                is_sure.setEnabled(false);
                reject_btn.setEnabled(false);
            }

        }

        ;
    };

    private void disloading() {
        Loading.hideDialogForLoading();
    }

    // 【客户家庭成员信息】
    public class CustomerFamilyListInfo {
        private String memberName;// 客户姓名
        private String documentType;// 证件类型
        private String documentNumber;// 证件号码

        public String getMemberName() {
            return memberName;
        }

        public void setMemberName(String memberName) {
            this.memberName = memberName;
        }

        public String getDocumentType() {
            return documentType;
        }

        public void setDocumentType(String documentType) {
            this.documentType = documentType;
        }

        public String getDocumentNumber() {
            return documentNumber;
        }

        public void setDocumentNumber(String documentNumber) {
            this.documentNumber = documentNumber;
        }
    }

    class RecordTaskUpdate extends AsyncTask<Void, Integer, Void> {
        String type = "1";
        int type2 = 0;

        public RecordTaskUpdate(String type, int type2) {
            this.type = type;
            this.type2 = type2;
        }

        @Override
        protected Void doInBackground(Void... arg0) {
            ArrayList<ImageListInfo> contentList_ = new ArrayList<ImageListInfo>();
            if (EmmApplication.pir.size() > 0) {
                for (int i = 0; i < EmmApplication.pir.size(); i++) {
                    if ("1".equals(EmmApplication.pir.get(i).type)) {
                        ImageListInfo content = new ImageListInfo();
                        content.setSignedUrl(EmmApplication.setPatchRtString(EmmApplication.pir.get(i).sourcePath));
                        content.setHeadType(".jpg");
                        contentList_.add(content);
                    }
                }
            } else {
                for (int m = 0; m < ap2.size(); m++) {
                    ImageListInfo content = new ImageListInfo();
                    content.setSignedUrl(ap2.get(m).getPath());
                    content.setHeadType("1");
                    contentList_.add(content);
                }
            }

            for (int m = 0; m < ap2.size(); m++) {
                int p = 0;
                for (int u = 0; u < EmmApplication.pir.size(); u++) {
                    if ("2".equals(EmmApplication.pir.get(u).type)) {
                        if (ap2.get(m).getPath().equals(EmmApplication.pir.get(u).sourcePath)) {
                            p++;
                        }
                    }
                }
                if (p > 0) {
                    ImageListInfo content = new ImageListInfo();
                    content.setSignedUrl(ap2.get(m).getPath());
                    content.setHeadType("0");
                    contentList_.add(content);
                } else {
                    ImageListInfo content = new ImageListInfo();
                    content.setSignedUrl(ap2.get(m).getPath());
                    content.setHeadType("1");
                    contentList_.add(content);
                }
            }

            AddSigned(contentList_, type, type2);
            return null;
        }

        // 当在上面方法中调用publishProgress时，该方法触发,该方法在I线程中被执行
        protected void onProgressUpdate(Integer... progress) {
        }

        protected void onPostExecute(Void result) {
        }

        protected void onPreExecute() {
        }

    }

    /**
     * 客户详情
     */
    GetCustomerDetail details;

    /**
     * <p>
     * <b>Title：</b> 客户详情
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @param customerId
     * @author tangxin
     * @date 2016年12月7日 下午3:56:38
     */
    private void getCustomerDetail(String customerId) {
        EmmApplication.updateUrl("getCustomerDetail");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        map.put("customerId", customerId);
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getCustomerDetail-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.hideDialogForLoading();
                Loading.showDialogForLoading(NewSignedActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                details = JSONObject.parseObject(resData.toString(), GetCustomerDetail.class);
                if ("1".equals(details.getResult())) {
                    Log.v("获取成功", "");

                    customerName_view.setText(EmmApplication.isNull(details.getCustomerName()) == false ? "" : details
                            .getCustomerName());
                    zj_type.setText(EmmApplication.isNull(details.getPeDocumentType()) == false ? "" : details
                            .getPeDocumentType());
                    peDocumentNumber_view.setText(EmmApplication.isNull(details.getPeDocumentNumber()) == false ? ""
                            : details.getPeDocumentNumber());
                    customerPhone_view.setText(EmmApplication.isNull(details.getCustomerPhone()) == false ? "" : details
                            .getCustomerPhone());
                    String str2 = "";
                    if ("".equals(details.getPeContactAddress()) || "null".equals(details.getPeContactAddress())
                            || TextUtils.isEmpty(details.getPeContactAddress())) {
                        str2 = "";
                    } else {
                        str2 = details.getPeContactAddress();
                    }
                    select_address.setText(EmmApplication.isNull(str2) == false ? "" : str2);
                    pePostcode_view.setText(EmmApplication.isNull(details.getPePostcode()) == false ? "" : details
                            .getPePostcode());

                    if ("6".equals(OpenType)) {
                    } else {
                        if ("商业按揭".equals(details.getRqPaymentMethod())) {
                            pay_type.setText("商业贷款");
                        } else if ("公积金按揭".equals(details.getRqPaymentMethod())) {
                            pay_type.setText("公积金贷款");
                        } else {
                            pay_type.setText(details.getRqPaymentMethod());
                        }
                    }
                    getsignedhaveamount();
                } else {
                    try {
                        EmmApplication.Ts(details.getErrorMsg().toString());
                        Log.v("获取失败", "errorCode:" + details.getErrorCode().toString() + "errorMsg:"
                                + details.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("新增认筹+客户详情，错误信息获取空指针异常", "");
                    }

                }
            }
        });
    }

    /**
     * 获取已收金额
     */
    GetSignedHaveAmount getsignedhaveamount;

    /**
     * <p>
     * <b>Title：</b> 获取已收金额
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午2:30:41
     */
    private void getsignedhaveamount() {
        EmmApplication.updateUrl("getSignedHaveAmount");
        Map<String, String> map = new HashMap<String, String>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("projectCode", EmmApplication.getProjectCode());
        if ("1".equals(OpenType)) {// 1新增 非1修改 5无房认筹转签约(或6认购转签约)
            map.put("businessId", "");
            map.put("businessType", "3");
        } else if ("5".equals(OpenType)) {// 认筹
            map.put("businessId", payDepositId);
            map.put("businessType", "1");
        } else if ("6".equals(OpenType)) {// 认购
            map.put("businessId", subscribeId);
            map.put("businessType", "2");
        } else {
            map.put("businessId", signId);
            map.put("businessType", "4");
        }
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getCustomerDetail-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Loading.hideDialogForLoading();
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Loading.hideDialogForLoading();
                Loading.showDialogForLoading(NewSignedActivity.this, "正在加载...", false, true, 60000);
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }

                getsignedhaveamount = JSONObject.parseObject(resData.toString(), GetSignedHaveAmount.class);
                if ("1".equals(getsignedhaveamount.getResult())) {
                    Log.v("获取成功", "");

                    if (EmmApplication.isNull(realAmount)) {
                    } else {
                        realAmount = "0";
                    }
                    if (EmmApplication.isNull(getsignedhaveamount.getRealAmount())) {
                    } else {
                        getsignedhaveamount.setRealAmount("0");
                        getsignedhaveamount.setRealAmount(EmmApplication.drop2(""
                                + (Double.valueOf(getsignedhaveamount.getRealAmount()).doubleValue() + Double.valueOf(
                                realAmount).doubleValue())));
                    }

                    yc_x_1.setText((EmmApplication.isNull(getsignedhaveamount.getRealAmount()) == false ? "0"
                            : getsignedhaveamount.getRealAmount()) + "元");

                    zuhe_w_1.setText((EmmApplication.isNull(getsignedhaveamount.getRealAmount()) == false ? "0"
                            : getsignedhaveamount.getRealAmount()) + "元");
                    sy_x_1.setText((EmmApplication.isNull(getsignedhaveamount.getRealAmount()) == false ? "0"
                            : getsignedhaveamount.getRealAmount()) + "元");

                    fq_x_1.setText((EmmApplication.isNull(getsignedhaveamount.getRealAmount()) == false ? "0"
                            : getsignedhaveamount.getRealAmount()) + "元");

                    gjj_x_1.setText((EmmApplication.isNull(getsignedhaveamount.getRealAmount()) == false ? "0"
                            : getsignedhaveamount.getRealAmount()) + "元");
                } else {
                    try {
                        EmmApplication.Ts(getsignedhaveamount.getErrorMsg().toString());
                        Log.v("获取失败", "errorCode:" + getsignedhaveamount.getErrorCode().toString() + "errorMsg:"
                                + getsignedhaveamount.getErrorMsg().toString());
                    } catch (NullPointerException e) {
                        Log.v("新增认筹+客户详情，错误信息获取空指针异常", "");
                    }

                }
            }
        });
    }

    public static class ImageListInfo {

        private String headType;// 上传头像后缀名

        private String signedUrl;// 签约拍照图片（图片文件流）

        public String getHeadType() {
            return headType;
        }

        public void setHeadType(String headType) {
            this.headType = headType;
        }

        public String getSignedUrl() {
            return signedUrl;
        }

        public void setSignedUrl(String signedUrl) {
            this.signedUrl = signedUrl;
        }
    }

    /**
     * <p>
     * <b>Title：</b> 填充数据
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:56:53
     */
    private void SetDataView() {
        GetSignedDetail getsigned = EmmApplication.getsigned;

        String decorationPaymentMethod = getsigned.getDecorationPaymentMethod();
        if (!TextUtils.isEmpty(decorationPaymentMethod)) {  //有装修款
            sb_fitment.setChecked(true);
            et_fitment_pay_type.setText(decorationPaymentMethod);
            List<GetSignedDetail.PaymentMethodList> list = getsigned.getDecorationPaymentMethodList();
            fitment_once_pay.setVisibility(View.GONE);
            switch (decorationPaymentMethod) {
                case "一次性付款":
                    fitment_once_pay.setVisibility(View.VISIBLE);
                    if (list != null && list.size() > 0) {
                        etFitmentReceivePrice.setText(list.get(0).getReceivable());
                        etFitmentReceiveDate.setText(list.get(0).getReceivableDate());
                        tvFitmentReceivedPrice.setText(list.get(0).getRealAmount() + "元");
                        tvFitmentUnreceivedPrice.setText(list.get(0).getReceivable() + "元");
                    }
                    break;
                case "分期付款":
                    fitment_fenqifukuan.setVisibility(View.VISIBLE);
                    if (list != null && list.size() > 0) {
                        for (GetSignedDetail.PaymentMethodList payment : list) {
                            if (payment.getPayContent().contains("一期")) {
                                etFitmentFirstPay.setText(payment.getReceivable());
                                etFitmentFirstDate.setText(payment.getReceivableDate());
                                tvFitmentFirstReceive.setText(payment.getRealAmount() + "元");
                                tvFitmentFirstUnreceive.setText(payment.getReceivable() + "元");
                            } else if (payment.getPayContent().contains("二期")) {
                                etFitmentSecondPay.setText(payment.getReceivable());
                                etFitmentSecondDate.setText(payment.getReceivableDate());
                                tvFitmentSecondReceive.setText(payment.getRealAmount() + "元");
                                tvFitmentSecondUnreceive.setText(payment.getReceivable() + "元");
                            } else if (payment.getPayContent().contains("三期")) {
                                etFitmentThirdPay.setText(payment.getReceivable());
                                etFitmentThirdDate.setText(payment.getReceivableDate());
                                tvFitmentThirdReceive.setText(payment.getRealAmount() + "元");
                                tvFitmentThirdUnreceive.setText(payment.getReceivable() + "元");
                            } else if (payment.getPayContent().contains("四期")) {
                                etFitmentFourthPay.setText(payment.getReceivable());
                                etFitmentFourthDate.setText(payment.getReceivableDate());
                                tvFitmentFourthReceive.setText(payment.getRealAmount() + "元");
                                tvFitmentFourthUnreceive.setText(payment.getReceivable() + "元");
                            } else if (payment.getPayContent().contains("五期")) {
                                etFitmentFifthPay.setText(payment.getReceivable());
                                etFitmentFifthDate.setText(payment.getReceivableDate());
                                tvFitmentFifthReceive.setText(payment.getRealAmount() + "元");
                                tvFitmentFifthUnreceive.setText(payment.getReceivable() + "元");
                            }
                        }
                    }
                    break;
                case "商业按揭":
                    fitment_shangyedaikuan.setVisibility(View.VISIBLE);
                    if (list != null && list.size() > 1) {
                        etFitmentHeadPay.setText(list.get(0).getReceivable());
                        etFitmentHeadDate.setText(list.get(0).getReceivableDate());
                        tvFitmentHeadReceive.setText(list.get(0).getRealAmount() + "元");
                        tvFitmentHeadUnreceive.setText(list.get(0).getReceivable() + "元");
                        etFitmentWorkPay.setText(list.get(1).getReceivable());
                        etEtFitmentWorkDate.setText(list.get(1).getReceivableDate());
                        tvFitmentWorkReceive.setText(list.get(1).getRealAmount() + "元");
                        tvFitmentWorkUnreceive.setText(list.get(1).getReceivable() + "元");
                    }
                    break;
                default:
                    break;
            }
        }
        String busreturntypel;
        try {
            busreturntypel = getsigned.getBusReturnType();
        } catch (Exception e) {
            busreturntypel = "0";
        }
        if (EmmApplication.isNull(busreturntypel)) {
            if ("1".equals(busreturntypel)) {// 0 无； 1 认筹； 2 认购
                realAmount_t1_lineas.setVisibility(View.VISIBLE);
                lllines.setVisibility(View.VISIBLE);
                realAmount_t2.setText(getsigned.getRealAmount());
                realAmount_t1.setText("已收认筹金");
            } else if ("2".equals(busreturntypel)) {
                realAmount_t1_lineas.setVisibility(View.VISIBLE);
                lllines.setVisibility(View.VISIBLE);
                realAmount_t2.setText(getsigned.getRealAmount());
                realAmount_t1.setText("已收认购金");
            }
        } else {
            realAmount_t1_lineas.setVisibility(View.GONE);
            lllines.setVisibility(View.GONE);
        }

        Hdnumber = getsigned.getDiscountRate();

        if (false == EmmApplication.isNull(Hdnumber)) {
            Hdnumber = "0";
        }

        number2.setText(Hdnumber + "%");
        if (null != getsigned.getDealCategoryList() && getsigned.getDealCategoryList().size() > 0) {
            for (int i = 0; i < getsigned.getDealCategoryList().size(); i++) {
                JJInfo jinfo = new JJInfo();
                jinfo.setName(getsigned.getDealCategoryList().get(i).getRelationAgentName());
                jinfo.setNumber(getsigned.getDealCategoryList().get(i).getProportionCommission());
                jinfo.setPid(getsigned.getDealCategoryList().get(i).getRelationAgentId());
                jjlist.add(jinfo);
            }
            jjadapter = new JJAdapter(jjlist, NewSignedActivity.this, getconsultan.getConsultantList());
            jj_list.setAdapter(jjadapter);
            jjadapter.SetType(0);
        }

        signedDepositCode_view.setText(getsigned.getSignedCode());
        housing_btn.setText(getsigned.getSignedHouses());
        calculateArea_view.setText(getsigned.getCalculateArea());
        discountPrice_view.setText(getsigned.getDiscountPrice());
        discountTotalPrice_view.setText(getsigned.getDiscountTotalPrice());
        customerName_view.setText(getsigned.getCustomerName());
        zj_type.setText(getsigned.getDocumentType());
        peDocumentNumber_view.setText(getsigned.getDocumentNumber());
        customerPhone_view.setText(getsigned.getCustomerPhone());
        select_address.setText(getsigned.getMailPost());
        pePostcode_view.setText(getsigned.getPostcode());
        if (null != getsigned.getCustomerFamilyList() && getsigned.getCustomerFamilyList().size() > 0) {
            if (list != null) {
                list.clear();
            } else {
                list = new ArrayList<NewClassKehuModel>();
            }
            for (int i = 0; i < getsigned.getCustomerFamilyList().size(); i++) {
                NewClassKehuModel m = new NewClassKehuModel();
                m.setCode(getsigned.getCustomerFamilyList().get(i).getDocumentNumber());
                m.setName(getsigned.getCustomerFamilyList().get(i).getMemberName());
                m.setNumber("" + (i + 1));
                m.setType(getsigned.getCustomerFamilyList().get(i).getDocumentType());
                list.add(m);
            }
            adapter = new NewFromAdapter(NewSignedActivity.this, list);
            kehuxinxi.setAdapter(adapter);
            adapter.SetType(0);
        }

        try {
            discountAmount_all_view.setText(getsigned.getDiscountAfterAmount());
        } catch (Exception e) {
            discountAmount_all_view.setText("");
        }
        if (EmmApplication.isNull(getsigned.getFloorType())) {
            PriceType = Integer.valueOf(getsigned.getFloorType()).intValue();
        }

        discountAmount_view.setText(getsigned.getDiscountAmount());

        try {
            discountRate_view.setText(getsigned.getAddDiscountRate());
        } catch (NullPointerException e) {
        }

        discountNote_view.setText(getsigned.getDiscountNote());
        contractPrice_view.setText(getsigned.getSignPrice());
        contractAmount_view.setText(getsigned.getContractAmount());
        String paymentMethod = getsigned.getPaymentMethod();
        pay_type.setText(paymentMethod);

        onest_pay.setVisibility("一次性付款".equals(paymentMethod) ? View.VISIBLE : View.GONE);
        include_zuhedaikuan.setVisibility("组合贷款".equals(paymentMethod) ? View.VISIBLE : View.GONE);
        include_shangyedaikuan.setVisibility("商业按揭".equals(paymentMethod) ? View.VISIBLE : View.GONE);
        include_gongjijindaikuan.setVisibility("公积金按揭".equals(paymentMethod) ? View.VISIBLE : View.GONE);
        include_fenqifukuan.setVisibility("分期付款".equals(paymentMethod) ? View.VISIBLE : View.GONE);

        if ("组合贷款".equals(paymentMethod)) {
            if (null != getsigned.getPaymentMethodList()) {
                for (int i = 0; i < getsigned.getPaymentMethodList().size(); i++) {
                    if ("首付".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "组合贷款首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        zuhe_pay1s.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        shoufu_1.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        zuhe_w_1.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        zuhe_w_2.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("商业按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "银行按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "组合贷款银行按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "组合贷款按揭银行".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        zuhe_pay2s.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        shangye_1.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        zuhe_w_3.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        zuhe_w_4.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("组合贷款公积金按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "公积金".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        zuhe_pay3s.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        gongjijin_1.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        zuhe_w_5.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        zuhe_w_6.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                }
            } else {
                Log.v(TAG, "组合贷款  支付list为空");
            }
        } else if ("一次性付款".equals(paymentMethod) || "一次性全款".equals(paymentMethod)) {
            if (null != getsigned.getPaymentMethodList() && getsigned.getPaymentMethodList().size() > 0) {
                receivable_view.setText(getsigned.getPaymentMethodList().get(0).getReceivable());
                String styy = getsigned.getPaymentMethodList().get(0).getReceivableDate();
                p_jjrmine.setText(styy);
                yc_x_1.setText(getsigned.getPaymentMethodList().get(0).getRealAmount() + "元");
                yc_x_2.setText(getsigned.getPaymentMethodList().get(0).getNotRealAmount() + "元");
            } else {
                Log.v(TAG, "一次性付款  支付list为空");
            }
        } else if ("商业按揭".equals(paymentMethod)) {
            if (null != getsigned.getPaymentMethodList()) {
                for (int i = 0; i < getsigned.getPaymentMethodList().size(); i++) {
                    if ("首付".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "商业按揭首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "商业贷款首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        s_first_pay2.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        shoufu_2.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        sy_x_1.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        sy_x_2.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("商业按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "银行按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "商业按揭按揭银行".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "商业按揭银行按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "商业贷款按揭款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        work_pay2.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        shangye_2.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        sy_x_3.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        sy_x_4.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                }
            } else {
                Log.v(TAG, "商业贷款  支付list为空");
            }
        } else if ("公积金按揭".equals(paymentMethod)) {
            if (null != getsigned.getPaymentMethodList()) {
                for (int i = 0; i < getsigned.getPaymentMethodList().size(); i++) {
                    if ("首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "首付".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "公积金按揭首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "公积金首付款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        first_pay1.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        shoufu_3.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        gjj_x_1.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        gjj_x_2.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("公积金按揭公积金按揭".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "公积金".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "公积金按揭款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        ggj_pay1.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        gongjijin_3.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        gjj_x_3.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        gjj_x_4.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                }
            } else {
                Log.v(TAG, "公积金贷款  支付list为空");
            }
        } else if ("分期付款".equals(paymentMethod)) {
            if (null != getsigned.getPaymentMethodList()) {
                for (int i = 0; i < getsigned.getPaymentMethodList().size(); i++) {
                    if ("一期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期付款一期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期一期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        pay_date_1.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        fenqi_1.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        fq_x_1.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        fq_x_2.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("二期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期付款二期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期二期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        pay_date_2.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        fenqi_2.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        fq_x_3.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        fq_x_4.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("三期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期付款三期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期三期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        pay_date_3.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        fenqi_3.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        fq_x_5.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        fq_x_6.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("四期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期付款四期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期四期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        pay_date_4.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        fenqi_4.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        fq_x_7.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        fq_x_8.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                    if ("五期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期付款五期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())
                            || "分期五期款".equals(getsigned.getPaymentMethodList().get(i).getPayContent())) {
                        pay_date_5.setText(getsigned.getPaymentMethodList().get(i).getReceivable());
                        fenqi_5.setText(getsigned.getPaymentMethodList().get(i).getReceivableDate());
                        fq_x_9.setText(getsigned.getPaymentMethodList().get(i).getRealAmount() + "元");
                        fq_x_10.setText(getsigned.getPaymentMethodList().get(i).getNotRealAmount() + "元");
                    }
                }
            } else {
                Log.v(TAG, "分期付款  支付list为空");
            }
        }
        try {
            pad_type_fund.setText(getsigned.getDealCategory());
            if ("推荐成交".equals(getsigned.getDealCategory())) {
                reference_linear_layout.setVisibility(View.VISIBLE);
                referenceName.setText(getsigned.getReferenceName());
                referenceProportion.setText(getsigned.getReferenceProportion());
            } else {
                reference_linear_layout.setVisibility(View.GONE);
            }
        } catch (Exception e) {
        }
        qianyue_time.setText(getsigned.getSignedDate());
        remark_view.setText(getsigned.getRemark());
        if (null != getsigned.getImageList() && getsigned.getImageList().size() > 0) {
            for (int i = 0; i < getsigned.getImageList().size(); i++) {
                AddpirModel a = new AddpirModel();
                a.setIsnet("2");
                a.setType("1");
                a.setPath("" + getsigned.getImageList().get(i).getSmallUrl());
                ap.add(0, a);
                ImageItem ima = new ImageItem();
                ima.type = "2";
                ima.imageId = EmmApplication.geTimes() + i;
                ima.sourcePath = getsigned.getImageList().get(i).getSmallUrl();
                EmmApplication.pir.add(ima);
                ap2.add(a);
            }
        }
        padapter.SetDate(ap);

        if ("0".equals(getsigned.getAnnexNum()) || null == getsigned.getAnnexNum()
                || "null".equals(getsigned.getAnnexNum())) {
            annex_layout.setVisibility(View.GONE);
        } else {
            annexNum_view.setText("存在以下" + getsigned.getAnnexNum() + "个非图片附件，请通过电脑端查看  ");
            annex_layout.setVisibility(View.VISIBLE);
            AnnexAdapter annexAdapter = new AnnexAdapter(NewSignedActivity.this, getsigned.getAnnexList());
            annexList_list.setAdapter(annexAdapter);
        }
    }

    class PaymentMethodListinfo {// 【支付方式列表】 N
        private String payContent;// 款项名称 String(50)
        // 款项名称：例付款方式选择1、‘一次性付款’，该字段入参为‘一次性付款’；2、
        // 组合贷款入参‘首付’、‘商业按揭’，‘公积金按揭’；3、其他类似 N
        private String receivable;// 应收金额 String(19) 应收金额 N
        private String receivableDate;// 应收日期 String(19) 应收日期格式：yyyy-MM-dd N

        public String getPayContent() {
            return payContent;
        }

        public void setPayContent(String payContent) {
            this.payContent = payContent;
        }

        public String getReceivable() {
            return receivable;
        }

        public void setReceivable(String receivable) {
            this.receivable = receivable;
        }

        public String getReceivableDate() {
            return receivableDate;
        }

        public void setReceivableDate(String receivableDate) {
            this.receivableDate = receivableDate;
        }
    }

    /**
     * 一次性已收
     */
    TextView yc_x_1;

    /**
     * 一次性未收
     */
    TextView yc_x_2;

    /**
     * 组合 首付已收
     */
    TextView zuhe_w_1;

    /**
     * 组合 首付未收
     */
    TextView zuhe_w_2;

    /**
     * 组合 商业已收
     */
    TextView zuhe_w_3;

    /**
     * 组合 商业未收
     */
    TextView zuhe_w_4;

    /**
     * 组合 公积金已收
     */
    TextView zuhe_w_5;

    /**
     * 组合 公积金未收
     */
    TextView zuhe_w_6;

    /**
     * 商业首付已收
     */
    TextView sy_x_1;

    /**
     * 商业首付未收
     */
    TextView sy_x_2;

    /**
     * 商业已收
     */
    TextView sy_x_3;

    /**
     * 商业未收
     */
    TextView sy_x_4;

    /**
     * 公积金首付已收
     */
    TextView gjj_x_1;

    /**
     * 公积金首付未收
     */
    TextView gjj_x_2;

    /**
     * 公积金已收
     */
    TextView gjj_x_3;

    /**
     * 公积金未收
     */
    TextView gjj_x_4;

    /**
     * 分期一期款已收
     */
    TextView fq_x_1;

    /**
     * 分期一期款未收
     */
    TextView fq_x_2;

    /**
     * 分期二期款已收
     */
    TextView fq_x_3;

    /**
     * 分期二期款未收
     */
    TextView fq_x_4;

    /**
     * 分期三期款已收
     */
    TextView fq_x_5;

    /**
     * 分期三期款未收
     */
    TextView fq_x_6;

    /**
     * 分期四期款已收
     */
    TextView fq_x_7;

    /**
     * 分期四期款未收
     */
    TextView fq_x_8;

    /**
     * 分期五期款已收
     */
    TextView fq_x_9;

    /**
     * 分期五期款未收
     */
    TextView fq_x_10;

    /**
     * <p>
     * <b>Title：</b> 初始化view
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:57:29
     */
    private void initView2() {
        pay_date_1.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            pay_date_1.setText(pay_date_1.getText().toString()
                                    .substring(0, pay_date_1.getText().toString().length() - 1));
                            pay_date_1.setSelection(pay_date_1.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(pay_date_1.getText().toString()) ? pay_date_1.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(fq_x_1.getText().toString().trim()))
                            .doubleValue();
                    fq_x_2.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        pay_date_2.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            pay_date_2.setText(pay_date_2.getText().toString()
                                    .substring(0, pay_date_2.getText().toString().length() - 1));
                            pay_date_2.setSelection(pay_date_2.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(pay_date_2.getText().toString()) ? pay_date_2.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(fq_x_3.getText().toString().trim()))
                            .doubleValue();
                    fq_x_4.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        pay_date_3.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            pay_date_3.setText(pay_date_3.getText().toString()
                                    .substring(0, pay_date_3.getText().toString().length() - 1));
                            pay_date_3.setSelection(pay_date_3.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(pay_date_3.getText().toString()) ? pay_date_3.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(fq_x_5.getText().toString().trim()))
                            .doubleValue();
                    fq_x_6.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });
        pay_date_4.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            pay_date_4.setText(pay_date_4.getText().toString()
                                    .substring(0, pay_date_4.getText().toString().length() - 1));
                            pay_date_4.setSelection(pay_date_4.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(pay_date_4.getText().toString()) ? pay_date_4.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(fq_x_7.getText().toString().trim()))
                            .doubleValue();
                    fq_x_8.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });
        pay_date_5.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            pay_date_5.setText(pay_date_5.getText().toString()
                                    .substring(0, pay_date_5.getText().toString().length() - 1));
                            pay_date_5.setSelection(pay_date_5.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(pay_date_5.getText().toString()) ? pay_date_5.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(fq_x_9.getText().toString().trim()))
                            .doubleValue();
                    fq_x_10.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });
        ggj_pay1.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            ggj_pay1.setText(ggj_pay1.getText().toString()
                                    .substring(0, ggj_pay1.getText().toString().length() - 1));
                            ggj_pay1.setSelection(ggj_pay1.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double.valueOf(
                            EmmApplication.isNull(ggj_pay1.getText().toString()) ? ggj_pay1.getText().toString() : "0")
                            .doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(gjj_x_3.getText().toString().trim()))
                            .doubleValue();
                    gjj_x_4.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        first_pay1.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            first_pay1.setText(first_pay1.getText().toString()
                                    .substring(0, first_pay1.getText().toString().length() - 1));
                            first_pay1.setSelection(first_pay1.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(first_pay1.getText().toString()) ? first_pay1.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(gjj_x_1.getText().toString().trim()))
                            .doubleValue();
                    gjj_x_2.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        work_pay2.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            work_pay2.setText(work_pay2.getText().toString()
                                    .substring(0, work_pay2.getText().toString().length() - 1));
                            work_pay2.setSelection(work_pay2.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double.valueOf(
                            EmmApplication.isNull(work_pay2.getText().toString()) ? work_pay2.getText().toString() : "0")
                            .doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(sy_x_3.getText().toString().trim()))
                            .doubleValue();
                    sy_x_4.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        s_first_pay2.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            s_first_pay2.setText(s_first_pay2.getText().toString()
                                    .substring(0, s_first_pay2.getText().toString().length() - 1));
                            s_first_pay2.setSelection(s_first_pay2.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double.valueOf(
                            EmmApplication.isNull(s_first_pay2.getText().toString()) ? s_first_pay2.getText().toString()
                                    : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(sy_x_1.getText().toString().trim()))
                            .doubleValue();
                    sy_x_2.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        receivable_view.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            receivable_view.setText(receivable_view.getText().toString()
                                    .substring(0, receivable_view.getText().toString().length() - 1));
                            receivable_view.setSelection(receivable_view.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double.valueOf(
                            EmmApplication.isNull(receivable_view.getText().toString()) ? receivable_view.getText()
                                    .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(yc_x_1.getText().toString().trim()))
                            .doubleValue();
                    if (all1 > delete1) {
                        yc_x_2.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                    } else {
                        yc_x_2.setText("0元");
                    }
                }
            }
        });

        zuhe_pay1s.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            zuhe_pay1s.setText(zuhe_pay1s.getText().toString()
                                    .substring(0, zuhe_pay1s.getText().toString().length() - 1));
                            zuhe_pay1s.setSelection(zuhe_pay1s.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(zuhe_pay1s.getText().toString()) ? zuhe_pay1s.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(zuhe_w_1.getText().toString().trim()))
                            .doubleValue();
                    zuhe_w_2.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        zuhe_pay2s.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            zuhe_pay2s.setText(zuhe_pay2s.getText().toString()
                                    .substring(0, zuhe_pay2s.getText().toString().length() - 1));
                            zuhe_pay2s.setSelection(zuhe_pay2s.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(zuhe_pay2s.getText().toString()) ? zuhe_pay2s.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(zuhe_w_3.getText().toString().trim()))
                            .doubleValue();
                    zuhe_w_4.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });

        zuhe_pay3s.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != s.toString()) {
                    if (s.toString().indexOf(".") >= 0) {
                        if (s.toString().indexOf(".", s.toString().indexOf(".") + 1) > 0) {
                            // 已重复输入
                            zuhe_pay3s.setText(zuhe_pay3s.getText().toString()
                                    .substring(0, zuhe_pay3s.getText().toString().length() - 1));
                            zuhe_pay3s.setSelection(zuhe_pay3s.getText().toString().length());
                        }
                    }

                    // 添加非空校验
                    double all1 = Double
                            .valueOf(
                                    EmmApplication.isNull(zuhe_pay3s.getText().toString()) ? zuhe_pay3s.getText()
                                            .toString() : "0").doubleValue();
                    double delete1 = Double.valueOf(EmmApplication.removeY(zuhe_w_5.getText().toString().trim()))
                            .doubleValue();
                    zuhe_w_6.setText(EmmApplication.drop2("" + (all1 - delete1)) + "元");
                }
            }
        });
    }

    /**
     * 证件类型
     */
    ArrayList<RqBusNumList> DocumentType;

    /**
     * 字典数据源
     */
    NewGetDictionaryList getdiction;

    /**
     * <p>
     * <b>Title：</b> 查询字典列表接口
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:58:58
     */
    private void getDictionaryList() {
        EmmApplication.updateUrl("getDictionaryListByProjectId");
        Map<String, String> map = new HashMap<>();
        map.put("version", EmmApplication.getPackageManager(5));
        map.put("merchantId", EmmApplication.getData(EmmApplication.merchantId));
        map.put("token", EmmApplication.getToken());
        map.put("userId", EmmApplication.getUserId());
        map.put("terminalCode", EmmApplication.getPackageManager(2));
        map.put("busNumType", "12");
        map.put("busNum", "01");
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("params", map);
        JSONObject json = new JSONObject(paramsMap);
        String jsonstr = json.toString();
        RequestParams params = new RequestParams();
        params.put("body", jsonstr);
        Log.v("getDictionaryList-->post", EmmApplication.urlStr + "?body=" + jsonstr);
        AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
        asyncHttpClient.post(EmmApplication.urlStr, params, new AsyncHttpResponseHandler() {
            @Override
            public void onFailure(Throwable error, String content) {
                super.onFailure(error, content);
                Log.v(TAG, "请求结束error:" + error + "==" + content);
            }

            @Override
            public void onFinish() {
                Log.v(TAG, "请求结束");
                super.onFinish();
            }

            @Override
            public void onStart() {
                super.onStart();
                Log.v(TAG, "请求开始");
            }

            @Override
            public void onSuccess(String content) {
                super.onSuccess(content);
                if (content == null) {
                    return;
                }
                Log.v(TAG, "content==:" + content);
                JSONObject jsonObj = JSONObject.parseObject(content);
                JSONObject resData = (JSONObject) jsonObj.get("resData");
                if (resData == null) {
                    Log.v(TAG, "信息返回值为空");
                    return;
                }
                getdiction = JSONObject.parseObject(resData.toString(), NewGetDictionaryList.class);
                if ("1".equals(getdiction.getResult())) {
                    DocumentType = getdiction.getTypeMap().getDocumentType();
                } else {
                    EmmApplication.T(getdiction.getErrorMsg().toString());
                    Log.v("获取失败", "errorCode:" + getdiction.getErrorCode().toString() + "errorMsg:"
                            + getdiction.getErrorMsg().toString());
                }
            }
        });
    }

    /**
     * 头像菜单
     */
    public View view3;

    /**
     * 头像菜单
     */
    public PopupWindow popu_phone;

    /**
     * 拍照图片路径
     */
    private Uri mImageCaptureUri;

    private static final int PICK_FROM_CAMERA = 1;

    /**
     * <p>
     * <b>Title：</b> 点击后的弹出框
     * </p>
     * <p>
     * <b>Description：</b>
     * </p>
     *
     * @author tangxin
     * @date 2016年12月7日 下午3:32:06
     */
    @SuppressLint("WrongConstant")
    public void popu() {
        view3 = LayoutInflater.from(NewSignedActivity.this).inflate(R.layout.item_popupwindow, null);
        popu_phone = new PopupWindow(view3, android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT,
                android.support.v4.view.ViewPager.LayoutParams.FILL_PARENT);
        popu_phone.setFocusable(true);

        popu_phone.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        popu_phone.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

        popu_phone.showAtLocation(view3, Gravity.BOTTOM, 0, 0);
        popu_phone.showAsDropDown(view3, 0, 0);
        popu_phone.setFocusable(true);
        popu_phone.setOutsideTouchable(true);
        view3.setFocusable(true);
        view3.setFocusableInTouchMode(true);

        view3.setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    popu_phone.dismiss();
                }
                return false;
            }
        });

        view3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popu_phone.dismiss();
            }
        });

        // 拍照
        Button item_popupwindows_camera = (Button) view3.findViewById(R.id.item_popupwindows_camera);
        // 相册
        Button item_popupwindows_Photo = (Button) view3.findViewById(R.id.item_popupwindows_Photo);
        // 取消
        Button item_popupwindows_cancel = (Button) view3.findViewById(R.id.item_popupwindows_cancel);

        item_popupwindows_cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popu_phone.dismiss();
            }
        });
        item_popupwindows_camera.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                popu_phone.dismiss();
                Album.camera(activity).start(PICK_FROM_CAMERA);
            }
        });
        item_popupwindows_Photo.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                EmmApplication.bitmap = null;
                popu_phone.dismiss();
                EmmApplication.setData("Picture", "1");
                EmmApplication.IsMoreSelect = true;
                startActivity(new Intent(NewSignedActivity.this, ImageBucketChooseActivity.class));
            }
        });
    }

    /**
     * 回调方法
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.w("a", +requestCode + "resultCode===" + resultCode + "RESULT_OK======" + RESULT_OK);
        if (resultCode != RESULT_OK) {
            return;
        }
        switch (requestCode) {
            case PICK_FROM_CAMERA:
                String path = Album.parseResult(data).get(0);
                Log.w("a", "拍照:+>" + path);

                ImageItem item = new ImageItem();
                item.sourcePath = path;
                item.imageId = "1101841324";
                EmmApplication.pir.add(item);

                SetImage();

                break;
            case 0:
                System.out.println("相册");
                break;
            case SELECT_CUSTOMER:
                GetCustomerList.CustomerList customer = (GetCustomerList.CustomerList) data.getSerializableExtra(CustomerFragment.CUSTOMER);
                customerId = customer.getCustomerId();
                getCustomerDetail(customerId);
                customerName_view.setText(customer.getCustomerName());
                customerPhone_view.setText(customer.getMobile());
                break;
            default:
                break;
        }
    }

}